source: XMLIO_V2/dev/common/src/xmlio/xml_node.cpp @ 219

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

Préparation nouvelle arborescence

File size: 2.5 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      { 
20         return (this->node->name()); 
21      }
22
23      bool CXMLNode::goToNextElement(void)
24      {
25         bool retvalue = false;
26         for(rapidxml::xml_node<char> * nextElement = this->node->next_sibling();
27                                      ; nextElement = this->node->next_sibling())
28         {
29            if (nextElement == NULL) break;
30            else if (nextElement->type() == rapidxml::node_element)
31            { 
32               node = nextElement;
33               return (!retvalue);
34            }
35         }
36         return (retvalue);
37      }
38
39      bool CXMLNode::goToChildElement(void)
40      {
41         bool retvalue = false;
42         rapidxml::xml_node<char> * nextElement = this->node->first_node();
43         if (nextElement != NULL)
44         {
45            for(;;nextElement = this->node->next_sibling())
46            {
47               if (nextElement == NULL) break;
48               else if (nextElement->type() == rapidxml::node_element)
49               { 
50                  node = nextElement; 
51                  return (!retvalue); 
52               }
53            }
54         }
55         return (retvalue);
56      }
57
58      bool CXMLNode::goToParentElement(void)
59      {
60         bool retvalue = false;
61         if (!(this->getElementName().compare(CXMLNode::RootName)))
62            return (retvalue);
63         node = node->parent();
64         return (!retvalue);
65      }
66
67      const StdString & CXMLNode::GetRootName(void)
68      { 
69         return (CXMLNode::RootName); 
70      }
71
72      THashAttributes CXMLNode::getAttributes(void) const
73      {
74         THashAttributes attributes;
75         rapidxml::xml_attribute<char> *currentAttr = NULL;
76
77         if ((currentAttr = this->node->first_attribute()) != NULL)
78         {
79            do 
80            {
81               attributes.insert(std::pair<StdString, StdString>
82                                (StdString(currentAttr->name()),
83                                 StdString(currentAttr->value())));
84            } while ((currentAttr = currentAttr->next_attribute()) != NULL);
85         }
86
87         return (attributes) ;
88      }
89
90   }// namespace xml
91} // namespace xmlioserve
Note: See TracBrowser for help on using the repository browser.