43 #ifndef XML_ATTRIBUTE_HPP 44 #define XML_ATTRIBUTE_HPP 85 std::string escaped(at_value);
88 std::string::size_type lPos = 0;
89 while((lPos = escaped.find(
'\n', lPos)) != std::string::npos)
91 escaped.replace(lPos++, 1,
"\\n");
93 os <<
get_name() <<
"=\"" << escaped <<
"\"";
123 auto it_end = a_list.end();
124 for(
auto it = a_list.begin(); it != it_end; ++it)
127 (*it)->print(os,
false,
nullptr);
140 if(a_map.find(name) != a_map.end())
149 xml_attributeRef at_ref(at);
150 a_list.push_back(at);
151 a_map[
name] = at_ref;
152 at->set_value(value);
163 if(a_map.find(name) == a_map.end())
169 return a_map.find(name)->second.get();
206 return !a_list.empty();
211 std::map<std::string, xml_attributeRef>
a_map;
std::string get_value() const
Get the value of this attribute.
std::list< xml_attribute * > attribute_list
bool has_attributes() const
attribute_list get_attributes()
Remove the attribute with this name.
xml_attribute(const std::string &_name)
constructor
static void convert_unescaped(std::string &ioString)
Convert unescaped characters.
const attribute_list & get_attributes() const
Obtain the list of attributes for this element.
redefinition of map to manage ordered/unordered structures
std::string get_name() const
Get the name of this node.
void print_attributes(std::ostream &os) const
Print the class.
xml_attribute * get_attribute(const std::string &name) const
Obtain the attribute with this name.
Template definition of refcount.
Very simple pretty printer functor.
std::map< std::string, xml_attributeRef > a_map
REF_FORWARD_DECL(xml_attribute)
void print(std::ostream &os, bool, simple_indent *) const override
Print the class.
xml_attribute * set_attribute(const std::string &name, const std::string &value)
Set the value of the attribute with this name, and optionally with this namespace.
std::string name
name of the node
void set_value(const std::string &value)
Set the value of this attribute.