source: XMLIO_V2/dev/dev_rv/src/xml_node.cpp @ 141

Last change on this file since 141 was 141, checked in by hozdoba, 13 years ago

Mise à jour depuis un autre dépôt

File size: 2.3 KB
Line 
1#include "xml_node.hpp"
2
3namespace xmlioserver
4{
5   namespace xml
6   {
7      /// ////////////////////// Définitions ////////////////////// ///
8
9      StdString CXMLNode::RootName("simulation");
10
11      CXMLNode::CXMLNode(rapidxml::xml_node<char> * const root)
12         : node(root)
13      { /* Ne rien faire de plus */ }
14
15      CXMLNode::~CXMLNode(void)
16      { /* Ne rien faire de plus */ }
17
18      StdString CXMLNode::getElementName(void) const
19      { return (this->node->name()); }
20
21      bool CXMLNode::goToNextElement(void)
22      {
23         bool retvalue = false;
24         for(rapidxml::xml_node<char> * nextElement = this->node->next_sibling();
25                                      ; nextElement = this->node->next_sibling())
26            if (nextElement == NULL) break;
27            else if (nextElement->type() == rapidxml::node_element)
28            { node = nextElement; return (!retvalue); }
29         return (retvalue);
30      }
31
32      bool CXMLNode::goToChildElement(void)
33      {
34         bool retvalue = false;
35         rapidxml::xml_node<char> * nextElement = this->node->first_node();
36         if (nextElement != NULL)
37         {
38            for(;;nextElement = this->node->next_sibling())
39               if (nextElement == NULL) break;
40               else if (nextElement->type() == rapidxml::node_element)
41               { node = nextElement; return (!retvalue); }
42         }
43         return (retvalue);
44      }
45
46      bool CXMLNode::goToParentElement(void)
47      {
48         bool retvalue = false;
49         if (!(this->getElementName().compare(CXMLNode::RootName)))
50            return (retvalue);
51         node = node->parent();
52         return (!retvalue);
53      }
54
55      const StdString & CXMLNode::GetRootName(void)
56      { return (CXMLNode::RootName); }
57
58      THashAttributes CXMLNode::getAttributes(void) const
59      {
60         THashAttributes attributes;
61         rapidxml::xml_attribute<char> *currentAttr = NULL;
62
63         if ((currentAttr = this->node->first_attribute()) != NULL)
64            do {
65               attributes.insert(std::pair<StdString, StdString>
66                                (StdString(currentAttr->name()),
67                                 StdString(currentAttr->value())));
68            } while ((currentAttr = currentAttr->next_attribute()) != NULL);
69
70         return (attributes) ;
71      }
72
73   }// namespace xml
74} // namespace xmlioserve
Note: See TracBrowser for help on using the repository browser.