libzypp  17.3.0
zypp::xml Namespace Reference

Namespaces

 detail
 
 parse_def_assign
 parseDefAssign exposed details
 

Classes

class  Node
 xmlTextReader based interface to Reader's current node. More...
 
class  ParseDef
 Define a xml node structure to parse. More...
 
struct  ParseDefBuildException
 Exceptions when building a ParseDef tree. More...
 
struct  ParseDefConsume
 Base class for ParseDef consumer. More...
 
class  ParseDefConsumeCallback
 ParseDef consumer that invokes callbacks. More...
 
class  ParseDefConsumeRedirect
 ParseDef consumer redirecting all events to another consumer. More...
 
struct  ParseDefDataException
 Parse exceptions related to the nodes content. More...
 
struct  ParseDefException
 Common base class for ParseDef exceptions. More...
 
struct  ParseDefImplConsume
 
struct  ParseDefTraits
 
struct  ParseDefValidateException
 Parse exceptions related to the documents node structure. More...
 
class  Reader
 xmlTextReader based interface to iterate xml streams. More...
 
struct  Validate
 xmlTextReader document validation. More...
 
class  XmlString
 xmlChar * wrapper. More...
 

Typedefs

typedef xmlTextReaderMode ReadState
 
typedef xmlReaderTypes NodeType
 

Functions

std::ostream & operator<< (std::ostream &str, const ReadState &obj)
 
std::ostream & operator<< (std::ostream &str, const NodeType &obj)
 
std::ostream & operator<< (std::ostream &str, const Node &obj)
 
template<class TData >
void rnParse (const InputStream &input_r, TData &data_r)
 Parse xml input_r and store data in data_r. More...
 
std::ostream & operator<< (std::ostream &str, const ParseDef::Impl &obj)
 
std::ostream & operator<< (std::ostream &str, ParseDef::Mode obj)
 
std::ostream & operator<< (std::ostream &str, const ParseDef &obj)
 
std::string unescape (const std::string &in_r)
 Unescape xml special charaters (& -> &; from IoBind library) More...
 
detail::EscapedString escape (const std::string &in_r)
 Escape xml special charaters (& -> &; from IoBind library). More...
 
std::ostream & operator<< (std::ostream &str, const XmlString &obj)
 

Typedef Documentation

◆ ReadState

typedef xmlTextReaderMode zypp::xml::ReadState

Definition at line 30 of file libxmlfwd.h.

◆ NodeType

typedef xmlReaderTypes zypp::xml::NodeType

Definition at line 34 of file libxmlfwd.h.

Function Documentation

◆ operator<<() [1/7]

std::ostream& zypp::xml::operator<< ( std::ostream &  str,
const ReadState obj 
)

Definition at line 29 of file libxmlfwd.cc.

◆ operator<<() [2/7]

std::ostream& zypp::xml::operator<< ( std::ostream &  str,
const NodeType obj 
)

Definition at line 50 of file libxmlfwd.cc.

◆ operator<<() [3/7]

std::ostream& zypp::xml::operator<< ( std::ostream &  str,
const Node obj 
)
related

Definition at line 57 of file Node.cc.

◆ rnParse()

template<class TData >
void zypp::xml::rnParse ( const InputStream input_r,
TData &  data_r 
)
inline

Parse xml input_r and store data in data_r.

TData must be defaultconstructible and assignable.

TData::RootNode must be a xml::ParseDef constructible from TData&.

Exceptions
ParseDefExceptionon parse errors.

To parse a xml file like this:

<test>
<setup attr="13">value</setup>
<list name="A"/>
<list name="b"/>
</test>

You need something like this:

struct XmlData
{
// data
unsigned attr;
std::string value;
std:list<std::string> names;
public:
// Convenience parsing to *this.
void parse( const Pathname & path_r )
{ xml::rnParse( path_r, *this ); }
public:
// Parser description
struct RootNode : public xml::ParseDef
{
RootNode( XmlData & data )
: ParseDef( "test", MANDTAORY )
, _data( data )
{
(*this)
("setup", MANDTAORY,
xml::parseDefAssign( data.value )
( "attr", data.attr ) )
// Each individual list entry is collected locally
// and appended to the list after the node is done.
("list", MULTIPLE_OPTIONAL,
xml::parseDefAssign( "name", _cname )
>> bind( &RootNode::cdone, this, _1 ) )
;
}
void cdone( const xml::Node & node_r )
{
_data.push_back( _cname );
_cname.clear(); // prepare for next
}
private:
XmlData & _data; // stored just because notification callbacks are used.
std::string _cname;
};
};
XmlData xmlData;
xmlData.parse( "/tmp/mytest.xml" );

Definition at line 97 of file Parse.h.

◆ operator<<() [4/7]

std::ostream& zypp::xml::operator<< ( std::ostream &  str,
const ParseDef::Impl obj 
)

Definition at line 348 of file ParseDef.cc.

◆ operator<<() [5/7]

std::ostream& zypp::xml::operator<< ( std::ostream &  str,
ParseDef::Mode  obj 
)
related

Definition at line 447 of file ParseDef.cc.

◆ operator<<() [6/7]

std::ostream& zypp::xml::operator<< ( std::ostream &  str,
const ParseDef obj 
)
related

Definition at line 466 of file ParseDef.cc.

◆ unescape()

ZYPP_API std::string zypp::xml::unescape ( const std::string &  in_r)

Unescape xml special charaters (& -> &; from IoBind library)

Definition at line 113 of file XmlEscape.cc.

◆ escape()

detail::EscapedString zypp::xml::escape ( const std::string &  in_r)
inline

Escape xml special charaters (& -> &; from IoBind library).

The detail::EscapedString can be dumped to an ostream and implicitly converts into a std::string.

Definition at line 51 of file XmlEscape.h.

◆ operator<<() [7/7]

std::ostream& zypp::xml::operator<< ( std::ostream &  str,
const XmlString obj 
)
related

Definition at line 46 of file XmlString.cc.