From 2b19c80a7e1c5522538734bc7ee18a38e94d50a9 Mon Sep 17 00:00:00 2001 From: kiritow <1362050620@qq.com> Date: Thu, 13 Apr 2017 16:19:35 +0800 Subject: [PATCH 1/6] Create header and source --- MiniEngine_Xml.cpp | 1 + MiniEngine_Xml.h | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 MiniEngine_Xml.cpp create mode 100644 MiniEngine_Xml.h diff --git a/MiniEngine_Xml.cpp b/MiniEngine_Xml.cpp new file mode 100644 index 0000000..7c31e77 --- /dev/null +++ b/MiniEngine_Xml.cpp @@ -0,0 +1 @@ +#include "MiniEngine_Xml.h" diff --git a/MiniEngine_Xml.h b/MiniEngine_Xml.h new file mode 100644 index 0000000..a5f1a4d --- /dev/null +++ b/MiniEngine_Xml.h @@ -0,0 +1,3 @@ +#pragma once +#include "MiniEngine.h" + From f9c2e872df47a6fc90fb0dfab43d94d15066bb22 Mon Sep 17 00:00:00 2001 From: kiritow <1362050620@qq.com> Date: Thu, 13 Apr 2017 20:28:16 +0800 Subject: [PATCH 2/6] Change rapidxml header to avoid compile errors --- rapidxml/rapidxml_print.hpp | 76 +++++++++++++++++++++++++++---------- 1 file changed, 55 insertions(+), 21 deletions(-) diff --git a/rapidxml/rapidxml_print.hpp b/rapidxml/rapidxml_print.hpp index d03d5f5..718db5f 100644 --- a/rapidxml/rapidxml_print.hpp +++ b/rapidxml/rapidxml_print.hpp @@ -28,10 +28,10 @@ namespace rapidxml //! \cond internal namespace internal { - + /////////////////////////////////////////////////////////////////////////// // Internal character operations - + // Copy characters from given range to given output iterator template inline OutIt copy_chars(const Ch *begin, const Ch *end, OutIt out) @@ -40,7 +40,7 @@ namespace rapidxml *out++ = *begin++; return out; } - + // Copy characters from given range to given output iterator and expand // characters into references (< > ' " &) template @@ -59,17 +59,17 @@ namespace rapidxml case Ch('<'): *out++ = Ch('&'); *out++ = Ch('l'); *out++ = Ch('t'); *out++ = Ch(';'); break; - case Ch('>'): + case Ch('>'): *out++ = Ch('&'); *out++ = Ch('g'); *out++ = Ch('t'); *out++ = Ch(';'); break; - case Ch('\''): + case Ch('\''): *out++ = Ch('&'); *out++ = Ch('a'); *out++ = Ch('p'); *out++ = Ch('o'); *out++ = Ch('s'); *out++ = Ch(';'); break; - case Ch('"'): + case Ch('"'): *out++ = Ch('&'); *out++ = Ch('q'); *out++ = Ch('u'); *out++ = Ch('o'); *out++ = Ch('t'); *out++ = Ch(';'); break; - case Ch('&'): - *out++ = Ch('&'); *out++ = Ch('a'); *out++ = Ch('m'); *out++ = Ch('p'); *out++ = Ch(';'); + case Ch('&'): + *out++ = Ch('&'); *out++ = Ch('a'); *out++ = Ch('m'); *out++ = Ch('p'); *out++ = Ch(';'); break; default: *out++ = *begin; // No expansion, copy character @@ -101,7 +101,41 @@ namespace rapidxml /////////////////////////////////////////////////////////////////////////// // Internal printing operations - + + /// Forward Declaration : Fix Compile Bug in MinGW + template + inline OutIt print_node(OutIt out, const xml_node *node, int flags, int indent); + + template + inline OutIt print_children(OutIt out, const xml_node *node, int flags, int indent); + + template + inline OutIt print_attributes(OutIt out, const xml_node *node, int flags); + + template + inline OutIt print_data_node(OutIt out, const xml_node *node, int flags, int indent); + + template + inline OutIt print_cdata_node(OutIt out, const xml_node *node, int flags, int indent); + + template + inline OutIt print_element_node(OutIt out, const xml_node *node, int flags, int indent); + + template + inline OutIt print_declaration_node(OutIt out, const xml_node *node, int flags, int indent); + + template + inline OutIt print_comment_node(OutIt out, const xml_node *node, int flags, int indent); + + template + inline OutIt print_doctype_node(OutIt out, const xml_node *node, int flags, int indent); + + template + inline OutIt print_pi_node(OutIt out, const xml_node *node, int flags, int indent); + + + + // Print node template inline OutIt print_node(OutIt out, const xml_node *node, int flags, int indent) @@ -119,12 +153,12 @@ namespace rapidxml case node_element: out = print_element_node(out, node, flags, indent); break; - + // Data case node_data: out = print_data_node(out, node, flags, indent); break; - + // CDATA case node_cdata: out = print_cdata_node(out, node, flags, indent); @@ -139,7 +173,7 @@ namespace rapidxml case node_comment: out = print_comment_node(out, node, flags, indent); break; - + // Doctype case node_doctype: out = print_doctype_node(out, node, flags, indent); @@ -155,7 +189,7 @@ namespace rapidxml assert(0); break; } - + // If indenting not disabled, add line break after node if (!(flags & print_no_indenting)) *out = Ch('\n'), ++out; @@ -163,8 +197,8 @@ namespace rapidxml // Return modified iterator return out; } - - // Print children of the node + + // Print children of the node template inline OutIt print_children(OutIt out, const xml_node *node, int flags, int indent) { @@ -249,7 +283,7 @@ namespace rapidxml *out = Ch('<'), ++out; out = copy_chars(node->name(), node->name() + node->name_size(), out); out = print_attributes(out, node, flags); - + // If node is childless if (node->value_size() == 0 && !node->first_node()) { @@ -308,11 +342,11 @@ namespace rapidxml // Print attributes out = print_attributes(out, node, flags); - + // Print declaration end *out = Ch('?'), ++out; *out = Ch('>'), ++out; - + return out; } @@ -384,7 +418,7 @@ namespace rapidxml //! \param node Node to be printed. Pass xml_document to print entire document. //! \param flags Flags controlling how XML is printed. //! \return Output iterator pointing to position immediately after last character of printed text. - template + template inline OutIt print(OutIt out, const xml_node &node, int flags = 0) { return internal::print_node(out, &node, flags, 0); @@ -397,7 +431,7 @@ namespace rapidxml //! \param node Node to be printed. Pass xml_document to print entire document. //! \param flags Flags controlling how XML is printed. //! \return Output stream. - template + template inline std::basic_ostream &print(std::basic_ostream &out, const xml_node &node, int flags = 0) { print(std::ostream_iterator(out), node, flags); @@ -408,7 +442,7 @@ namespace rapidxml //! \param out Output stream to print to. //! \param node Node to be printed. //! \return Output stream. - template + template inline std::basic_ostream &operator <<(std::basic_ostream &out, const xml_node &node) { return print(out, node); From fc4940c09bd4e8aa960ce6285c7bb786c3b9926d Mon Sep 17 00:00:00 2001 From: kiritow <1362050620@qq.com> Date: Wed, 17 May 2017 21:40:33 +0800 Subject: [PATCH 3/6] Add XML Objects Document,Node,Attribute... --- MiniEngine_Xml.cpp | 96 ++++++++++++++++++++++++++++++++++++++++++++++ MiniEngine_Xml.h | 87 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 182 insertions(+), 1 deletion(-) diff --git a/MiniEngine_Xml.cpp b/MiniEngine_Xml.cpp index 7c31e77..72491f8 100644 --- a/MiniEngine_Xml.cpp +++ b/MiniEngine_Xml.cpp @@ -1 +1,97 @@ #include "MiniEngine_Xml.h" +#include "rapidxml/rapidxml_print.hpp" +#include "rapidxml/rapidxml_utils.hpp" +#include + +namespace MiniEngine +{ + +namespace XML +{ + +Document::Document() +{ + _is_ready=false; +} + +Document::Document(const std::string& filename) +{ + if(loadFrom(filename,false)!=0) + { + _is_ready=false; + } + else + { + _is_ready=true; + } +} + +int Document::loadFrom(const std::string& filename, bool clearCurrent) +{ + std::ifstream ifs(filename); + if(!ifs) + { + /// File Read Error. + return -1; + } + rapidxml::file<> infilereader(ifs); + if(clearCurrent) + { + _doc.clear(); + } + _doc.parse<0>(infilereader.data()); + return 0; +} + +int Document::saveTo(const std::string& filename) +{ + std::string ans; + rapidxml::print(std::back_inserter(ans),_doc,0); + + std::ofstream ofs(filename); + + if(!ofs) return -1; + + ofs< + +namespace MiniEngine +{ + +namespace XML +{ + +typedef rapidxml::xml_node<> XNode; +typedef rapidxml::xml_attribute<> XAttr; +typedef rapidxml::xml_document<> XDoc; + +/// Fwd Decl +class Document; + +class Attribute +{ +private: + XAttr* _pattr; + Document* _pdoc; + friend class Document; +}; + +class Node +{ +public: + void push_front(const Node&); + void push_back(const Node&); + void insert(const Node& where,const Node& val); + + void remove_first_node(); + void remove_last_node(); + void remove_node(const Node& todelete); + void remove_all_node(); + + void push_front(const Attribute&); + void push_back(const Attribute&); + void insert(const Attribute& where,const Attribute& val); + + void remove_first_attr(); + void remove_last_attr(); + void remove_attr(const Attribute& todelete); + void remove_all_attr(); + + bool operator == (const Node& node) + { + return _pnode==node._pnode && _pdoc==node._pdoc; + } + + bool hasPrevNode() const; + bool hasNextNode() const; + bool hasParentNode() const; + Node getPrevNode() const; + Node getNextNode() const; + Node getParentNode() const; + +private: + XNode* _pnode; + Document* _pdoc; + friend class Document; +}; + +class Document +{ +public: + Document(); + Document(const std::string& filename); + int loadFrom(const std::string& filename,bool clearCurrent=true); + int saveTo(const std::string& filename); + bool ready(); + Node newNode(const std::string& name,const std::string& value); + Attribute newAttr(const std::string& name,const std::string& value); +protected: + char* _allocate_string(const std::string& str); + char* _allocate_string(const char* pstr,int sz); +private: + XDoc _doc; + bool _is_ready; +}; + + + +}/// End of namespace MiniEngine::XML + +}/// End of namespace MiniEngine From d47a3ed09d6250aa82ec090003d0228d3f9a6f79 Mon Sep 17 00:00:00 2001 From: kiritow <1362050620@qq.com> Date: Wed, 17 May 2017 23:24:43 +0800 Subject: [PATCH 4/6] Add support functions of XML Node --- MiniEngine_Xml.cpp | 111 +++++++++++++++++++++++++++++++++++++++++++-- MiniEngine_Xml.h | 17 ++++++- 2 files changed, 121 insertions(+), 7 deletions(-) diff --git a/MiniEngine_Xml.cpp b/MiniEngine_Xml.cpp index 72491f8..0bc26d9 100644 --- a/MiniEngine_Xml.cpp +++ b/MiniEngine_Xml.cpp @@ -9,6 +9,107 @@ namespace MiniEngine namespace XML { +void Node::push_front(const Node& node) +{ + _pnode->prepend_node(node._pnode); +} + +void Node::push_back(const Node& node) +{ + _pnode->append_node(node._pnode); +} + +void Node::insert(const Node& where, const Node& val) +{ + _pnode->insert_node(where._pnode,val._pnode); +} + +void Node::remove_first_node() +{ + _pnode->remove_first_node(); +} + +void Node::remove_last_node() +{ + _pnode->remove_last_node(); +} + +void Node::remove_node(const Node& todelete) +{ + _pnode->remove_node(todelete._pnode); +} + +void Node::remove_all_node() +{ + _pnode->remove_all_nodes(); +} + +void Node::push_front(const Attribute& attr) +{ + _pnode->prepend_attribute(attr._get()); +} + +void Node::push_back(const Attribute& attr) +{ + _pnode->append_attribute(attr._get()); +} + +void Node::insert(const Attribute& where, const Attribute& val) +{ + _pnode->insert_attribute(where._get(),val._get()); +} + +void Node::remove_first_attr() +{ + _pnode->remove_first_attribute(); +} + +void Node::remove_last_attr() +{ + _pnode->remove_last_attribute(); +} + +void Node::remove_attr(const Attribute& todelete) +{ + _pnode->remove_attribute(todelete._get()); +} + +void Node::remove_all_attr() +{ + _pnode->remove_all_attributes(); +} + +bool Node::hasPrevNode() const +{ + return _pnode->previous_sibling()!=nullptr; +} + +bool Node::hasNextNode() const +{ + return _pnode->next_sibling()!=nullptr; +} + +bool Node::hasParentNode() const +{ + return _pnode->parent()!=nullptr; +} + +Node Node::getPrevNode() const +{ + return Node(_pnode->previous_sibling()); +} + +Node Node::getNextNode() const +{ + return Node(_pnode->next_sibling()); +} + +Node Node::getParentNode() const +{ + return Node(_pnode->parent()); +} + + Document::Document() { _is_ready=false; @@ -65,17 +166,17 @@ bool Document::ready() Node Document::newNode(const std::string& name,const std::string& value) { Node node; - node._pnode=_doc.allocate_node(rapidxml::node_type::node_element, - _allocate_string(name),_allocate_string(value)); - node._pdoc=this; + node._set(_doc.allocate_node(rapidxml::node_type::node_element, + _allocate_string(name),_allocate_string(value))); + node._setdoc(this); return node; } Attribute Document::newAttr(const std::string& name,const std::string& value) { Attribute attr; - attr._pattr=_doc.allocate_attribute(_allocate_string(name),_allocate_string(value)); - attr._pdoc=this; + attr._set(_doc.allocate_attribute(_allocate_string(name),_allocate_string(value))); + attr._setdoc(this); return attr; } diff --git a/MiniEngine_Xml.h b/MiniEngine_Xml.h index 6d61abc..d4838a5 100644 --- a/MiniEngine_Xml.h +++ b/MiniEngine_Xml.h @@ -17,15 +17,27 @@ class Document; class Attribute { +public: + void _set(XAttr*); + XAttr* _get() const; + void _clear(); + void _setdoc(Document*); private: XAttr* _pattr; Document* _pdoc; - friend class Document; }; class Node { public: + void _set(XNode*); + XNode* _get(); + void _clear(); + void _setdoc(Document*); + + Node(); + Node(XNode*); + void push_front(const Node&); void push_back(const Node&); void insert(const Node& where,const Node& val); @@ -56,10 +68,11 @@ public: Node getNextNode() const; Node getParentNode() const; + Node clone(); + private: XNode* _pnode; Document* _pdoc; - friend class Document; }; class Document From 547be65c3ee6e9969afc0b5f69ba7637e8ad78a5 Mon Sep 17 00:00:00 2001 From: kiritow <1362050620@qq.com> Date: Thu, 18 May 2017 09:00:27 +0800 Subject: [PATCH 5/6] Add more functions to Attr and Node --- MiniEngine_Xml.cpp | 116 +++++++++++++++++++++++++++++++++++++++++++++ MiniEngine_Xml.h | 24 +++++++--- 2 files changed, 134 insertions(+), 6 deletions(-) diff --git a/MiniEngine_Xml.cpp b/MiniEngine_Xml.cpp index 0bc26d9..2ea9ab3 100644 --- a/MiniEngine_Xml.cpp +++ b/MiniEngine_Xml.cpp @@ -9,6 +9,102 @@ namespace MiniEngine namespace XML { +void Attribute::_set(XAttr* pattr) +{ + _pattr=pattr; +} + +XAttr* Attribute::_get() const +{ + return _pattr; +} + +void Attribute::_clear() +{ + _pattr=nullptr; +} + +void Attribute::_setdoc(Document* pDoc) +{ + _pdoc=pDoc; +} + +std::string Attribute::getName() const +{ + return std::string(getNameRaw()); +} + +std::string Attribute::getValue() const +{ + return std::string(getValueRaw()); +} + +char* Attribute::getNameRaw() const +{ + return _pattr->name(); +} + +char* Attribute::getValueRaw() const +{ + return _pattr->value(); +} + + +Node::Node() +{ + _pnode=nullptr; + _pdoc=nullptr; +} + +Node::Node(XNode* expNode) +{ + _pnode=expNode; + _pdoc=nullptr; +} + + + +void Node::_set(XNode* node) +{ + _pnode=node; +} + +XNode* Node::_get() const +{ + return _pnode; +} + +void Node::_clear() +{ + _pnode=nullptr; +} + +void Node::_setdoc(Document* pDoc) +{ + _pdoc=pDoc; +} + +std::string Node::getName() const +{ + return std::string(getNameRaw()); +} + +std::string Node::getValue() const +{ + return std::string(getValueRaw()); +} + +char* Node::getNameRaw() const +{ + return _pnode->name(); +} + +char* Node::getValueRaw() const +{ + return _pnode->value(); +} + + void Node::push_front(const Node& node) { _pnode->prepend_node(node._pnode); @@ -79,6 +175,11 @@ void Node::remove_all_attr() _pnode->remove_all_attributes(); } +bool Node::operator==(const Node& node) +{ + return _pnode==node._pnode && _pdoc==node._pdoc; +} + bool Node::hasPrevNode() const { return _pnode->previous_sibling()!=nullptr; @@ -109,6 +210,11 @@ Node Node::getParentNode() const return Node(_pnode->parent()); } +bool Node::valid() +{ + return _pnode!=nullptr && _pdoc!=nullptr; +} + Document::Document() { @@ -180,6 +286,16 @@ Attribute Document::newAttr(const std::string& name,const std::string& value) return attr; } +Node Document::cloneNode(const Node& node) +{ + return Node(_doc.clone_node(node._get())); +} + +void Document::clear() +{ + return _doc.clear(); +} + //protected char* Document::_allocate_string(const std::string& str) { diff --git a/MiniEngine_Xml.h b/MiniEngine_Xml.h index d4838a5..431ce02 100644 --- a/MiniEngine_Xml.h +++ b/MiniEngine_Xml.h @@ -22,6 +22,12 @@ public: XAttr* _get() const; void _clear(); void _setdoc(Document*); + + std::string getName() const; + std::string getValue() const; + + char* getNameRaw() const; + char* getValueRaw() const; private: XAttr* _pattr; Document* _pdoc; @@ -31,13 +37,19 @@ class Node { public: void _set(XNode*); - XNode* _get(); + XNode* _get() const; void _clear(); void _setdoc(Document*); Node(); Node(XNode*); + std::string getName() const; + std::string getValue() const; + + char* getNameRaw() const; + char* getValueRaw() const; + void push_front(const Node&); void push_back(const Node&); void insert(const Node& where,const Node& val); @@ -56,10 +68,7 @@ public: void remove_attr(const Attribute& todelete); void remove_all_attr(); - bool operator == (const Node& node) - { - return _pnode==node._pnode && _pdoc==node._pdoc; - } + bool operator == (const Node& node); bool hasPrevNode() const; bool hasNextNode() const; @@ -68,7 +77,7 @@ public: Node getNextNode() const; Node getParentNode() const; - Node clone(); + bool valid(); private: XNode* _pnode; @@ -85,6 +94,9 @@ public: bool ready(); Node newNode(const std::string& name,const std::string& value); Attribute newAttr(const std::string& name,const std::string& value); + Node cloneNode(const Node&); + void clear(); + protected: char* _allocate_string(const std::string& str); char* _allocate_string(const char* pstr,int sz); From 54e057b590b8c969b8cf9038a8e577a04e829a7c Mon Sep 17 00:00:00 2001 From: kiritow <1362050620@qq.com> Date: Sat, 20 May 2017 16:00:19 +0800 Subject: [PATCH 6/6] Add More Function of Attr and Node --- MiniEngine_Xml.cpp | 96 +++++++++++++++++++++++++++++++++++++++------- MiniEngine_Xml.h | 44 ++++++++++++++------- 2 files changed, 112 insertions(+), 28 deletions(-) diff --git a/MiniEngine_Xml.cpp b/MiniEngine_Xml.cpp index 2ea9ab3..7056b96 100644 --- a/MiniEngine_Xml.cpp +++ b/MiniEngine_Xml.cpp @@ -29,6 +29,18 @@ void Attribute::_setdoc(Document* pDoc) _pdoc=pDoc; } +Attribute::Attribute() +{ + _pattr=nullptr; + _pdoc=nullptr; +} + +Attribute::Attribute(XAttr* pAttr) +{ + _pattr=pAttr; + _pdoc=nullptr; +} + std::string Attribute::getName() const { return std::string(getNameRaw()); @@ -49,6 +61,27 @@ char* Attribute::getValueRaw() const return _pattr->value(); } +bool Attribute::hasPrevAttr() const +{ + return _pattr->previous_attribute()!=nullptr; +} + +bool Attribute::hasNextAttr() const +{ + return _pattr->next_attribute()!=nullptr; +} + +Attribute Attribute::getPrevAttr() const +{ + return Attribute(_pattr->previous_attribute()); +} + +Attribute Attribute::getNextAttr() const +{ + return Attribute(_pattr->next_attribute()); +} + + Node::Node() { @@ -105,74 +138,88 @@ char* Node::getValueRaw() const } -void Node::push_front(const Node& node) +Node& Node::push_front(const Node& node) { _pnode->prepend_node(node._pnode); + return *this; } -void Node::push_back(const Node& node) +Node& Node::push_back(const Node& node) { _pnode->append_node(node._pnode); + return *this; } -void Node::insert(const Node& where, const Node& val) +Node& Node::insert(const Node& where, const Node& val) { _pnode->insert_node(where._pnode,val._pnode); + return *this; } -void Node::remove_first_node() +Node& Node::remove_first_node() { _pnode->remove_first_node(); + return *this; } -void Node::remove_last_node() +Node& Node::remove_last_node() { _pnode->remove_last_node(); + return *this; } -void Node::remove_node(const Node& todelete) +Node& Node::remove_node(const Node& todelete) { _pnode->remove_node(todelete._pnode); + return *this; } -void Node::remove_all_node() +Node& Node::remove_all_node() { _pnode->remove_all_nodes(); + return *this; } -void Node::push_front(const Attribute& attr) +Node& Node::push_front(const Attribute& attr) { _pnode->prepend_attribute(attr._get()); + return *this; } -void Node::push_back(const Attribute& attr) +Node& Node::push_back(const Attribute& attr) { _pnode->append_attribute(attr._get()); + return *this; } -void Node::insert(const Attribute& where, const Attribute& val) +Node& Node::insert(const Attribute& where, const Attribute& val) { _pnode->insert_attribute(where._get(),val._get()); + return *this; } -void Node::remove_first_attr() +Node& Node::remove_first_attr() { _pnode->remove_first_attribute(); + return *this; } -void Node::remove_last_attr() +Node& Node::remove_last_attr() { _pnode->remove_last_attribute(); + return *this; } -void Node::remove_attr(const Attribute& todelete) +Node& Node::remove_attr(const Attribute& todelete) { _pnode->remove_attribute(todelete._get()); + return *this; } -void Node::remove_all_attr() +Node& Node::remove_all_attr() { _pnode->remove_all_attributes(); + return *this; } bool Node::operator==(const Node& node) @@ -205,6 +252,16 @@ Node Node::getNextNode() const return Node(_pnode->next_sibling()); } +Node Node::getPrevNode(const std::string& name) const +{ + return Node(_pnode->previous_sibling(name.c_str())); +} + +Node Node::getNextNode(const std::string& name) const +{ + return Node(_pnode->next_sibling(name.c_str())); +} + Node Node::getParentNode() const { return Node(_pnode->parent()); @@ -216,6 +273,17 @@ bool Node::valid() } +Node Node::getChild() const +{ + return _pnode->first_node(); +} + +Node Node::getChild(const std::string& nodename) const +{ + return _pnode->first_node(nodename.c_str()); +} + + Document::Document() { _is_ready=false; diff --git a/MiniEngine_Xml.h b/MiniEngine_Xml.h index 431ce02..fde952b 100644 --- a/MiniEngine_Xml.h +++ b/MiniEngine_Xml.h @@ -23,11 +23,22 @@ public: void _clear(); void _setdoc(Document*); + Attribute(); + Attribute(XAttr*); + std::string getName() const; std::string getValue() const; char* getNameRaw() const; char* getValueRaw() const; + + bool hasPrevAttr() const; + bool hasNextAttr() const; + Attribute getPrevAttr() const; + Attribute getNextAttr() const; + Attribute getPrevAttr(const std::string& name) const; + Attribute getNextAttr(const std::string& name) const; + private: XAttr* _pattr; Document* _pdoc; @@ -50,23 +61,23 @@ public: char* getNameRaw() const; char* getValueRaw() const; - void push_front(const Node&); - void push_back(const Node&); - void insert(const Node& where,const Node& val); + Node& push_front(const Node&); + Node& push_back(const Node&); + Node& insert(const Node& where,const Node& val); - void remove_first_node(); - void remove_last_node(); - void remove_node(const Node& todelete); - void remove_all_node(); + Node& remove_first_node(); + Node& remove_last_node(); + Node& remove_node(const Node& todelete); + Node& remove_all_node(); - void push_front(const Attribute&); - void push_back(const Attribute&); - void insert(const Attribute& where,const Attribute& val); + Node& push_front(const Attribute&); + Node& push_back(const Attribute&); + Node& insert(const Attribute& where,const Attribute& val); - void remove_first_attr(); - void remove_last_attr(); - void remove_attr(const Attribute& todelete); - void remove_all_attr(); + Node& remove_first_attr(); + Node& remove_last_attr(); + Node& remove_attr(const Attribute& todelete); + Node& remove_all_attr(); bool operator == (const Node& node); @@ -76,6 +87,11 @@ public: Node getPrevNode() const; Node getNextNode() const; Node getParentNode() const; + Node getPrevNode(const std::string& name) const; + Node getNextNode(const std::string& name) const; + + Node getChild() const; + Node getChild(const std::string& nodename) const; bool valid();