68 #define XML_TAB_SIZE 2 83 explicit xml_node(
const std::string& _name) : name(_name), line(0)
106 s.
print(os,
true, &PP);
115 s->
print(os,
true, &PP);
121 friend std::ostream&
operator<<(std::ostream& os,
const xml_nodeRef& s)
124 s->print(os,
true, &PP);
164 std::string::size_type lPos = 0;
165 while((lPos = ioString.find_first_of(
"&<>'\"", lPos)) != std::string::npos)
167 switch(ioString[lPos])
170 ioString.replace(lPos++, 1,
"&");
173 ioString.replace(lPos++, 1,
"<");
176 ioString.replace(lPos++, 1,
">");
179 ioString.replace(lPos++, 1,
"'");
182 ioString.replace(lPos++, 1,
""");
199 std::string::size_type lPos = 0;
200 while((lPos = ioString.find(
"&", lPos)) != std::string::npos)
202 ioString.replace(lPos++, 5,
"&");
205 while((lPos = ioString.find(
"<", lPos)) != std::string::npos)
207 ioString.replace(lPos++, 4,
"<");
210 while((lPos = ioString.find(
">", lPos)) != std::string::npos)
212 ioString.replace(lPos++, 4,
">");
215 while((lPos = ioString.find(
"'", lPos)) != std::string::npos)
217 ioString.replace(lPos++, 6,
"\'");
220 while((lPos = ioString.find(
""", lPos)) != std::string::npos)
222 ioString.replace(lPos++, 6,
"\"");
242 auto it_end = child_list.end();
243 for(
auto it = child_list.begin(); it != it_end; ++it)
245 (*it)->print(os, formatted, pp);
259 xml_element* add_child_element(
const xml_nodeRef& node);
328 return !child_list.empty();
Simple pretty print functor.
static void convert_unescaped(std::string &ioString)
Convert unescaped characters.
xml_child(const std::string &_name)
constructor
const node_list & get_children() const
Obtain the list of child nodes.
int line
The line number in the XML file (not unsigned because lineno function of the lexer returns an int) ...
REF_FORWARD_DECL(xml_node)
friend std::ostream & operator<<(std::ostream &os, const xml_node &s)
Friend definition of the << operator.
std::string get_name() const
Get the name of this node.
void set_name(const std::string &_name)
Set the name of this node.
friend std::ostream & operator<<(std::ostream &os, const xml_nodeRef &s)
Friend definition of the << operator.
redefinition of set to manage ordered/unordered structures
xml_text_node * first_text
int get_line() const
Discover at what line number this node occurs in the XML file.
virtual ~xml_node()=default
destructor
std::list< xml_nodeRef > node_list
type for list of xml nodes
#define STD_OPENING_CHAR
STD include.
virtual void print(std::ostream &os, bool formatted, simple_indent *pp) const =0
Print the class.
Template definition of refcount.
friend std::ostream & operator<<(std::ostream &os, const xml_node *s)
Friend definition of the << operator.
Very simple pretty printer functor.
#define STD_CLOSING_CHAR
Special closing character used to close the current nested level.
void set_line(int _line)
Set the line this node occurs in the XML file.
xml_text_node * get_child_text()
Get the first child text content node.
xml_node(const std::string &_name)
constructor
void print(std::ostream &os, bool formatted, simple_indent *pp) const override
Print the class.
node_list const & get_children()
Obtain the list of child nodes.
static void convert_escaped(std::string &ioString)
Convert escaped characters.
const xml_text_node * get_child_text() const
Get the first child text content node.
void remove_child(xml_node *el)
Remove the child node.
std::string name
name of the node