12 #ifndef ZYPP_BASE_XML_H
13 #define ZYPP_BASE_XML_H
37 std::string asXmlNodeAttr(
const Tp & val_r )
43 struct NodeAttr :
public std::pair<std::string,std::string>
45 typedef std::pair<std::string,std::string>
Pair;
47 template <
typename Tp>
48 NodeAttr( std::string key_r,
const Tp & val_r )
52 NodeAttr( std::string key_r, std::string val_r )
53 :
Pair( std::move(key_r), std::move(val_r) )
93 Node( std::ostream & out_r, std::string name_r,
const std::initializer_list<Attr> & attrs_r = {} )
98 Node( std::ostream & out_r, std::string name_r,
Attr attr_r )
99 :
Node( out_r, std::move(name_r), { attr_r } )
127 struct HasContentException{};
132 Node &
addAttr(
const std::initializer_list<Attr> & attrs_r = {} )
135 throw HasContentException();
142 {
return addAttr( { attr_r } ); }
160 void printStart(
const std::initializer_list<Attr> & attrs_r )
176 void printAttr(
const std::initializer_list<Attr> & attrs_r )
178 for (
const auto &
pair : attrs_r )
183 {
return _name.empty(); }
197 inline std::ostream &
node( std::ostream & out_r,
const std::string & name_r,
const std::initializer_list<Node::Attr> & attrs_r = {} )
203 inline std::ostream &
node( std::ostream & out_r,
const std::string & name_r,
Node::Attr attr_r )
204 {
return node( out_r, name_r, { attr_r } ); }
213 inline std::ostream &
dumpAsXmlOn( std::ostream & str,
const Tp & obj,
const std::string & name_r )
216 const std::string & content(
asString( obj ) );
217 if ( ! content.empty() ) *guard <<
xml::escape( content );
224 #endif // ZYPP_BASE_XML_H