source: XIOS/dev/XIOS_DEV_CMIP6/src/xml_node.cpp @ 1313

Last change on this file since 1313 was 591, checked in by rlacroix, 9 years ago

Remove leftovers from the XMLIO age.

  • Property copyright set to
    Software name : XIOS (Xml I/O Server)
    http://forge.ipsl.jussieu.fr/ioserver
    Creation date : January 2009
    Licence : CeCCIL version2
    see license file in root directory : Licence_CeCILL_V2-en.txt
    or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
    Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement)
    CNRS/IPSL (Institut Pierre Simon Laplace)
    Project Manager : Yann Meurdesoif
    yann.meurdesoif@cea.fr
File size: 2.8 KB
Line 
1#include "xml_node.hpp"
2
3namespace xios
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         , level(0)
14      { /* Ne rien faire de plus */ }
15
16      CXMLNode::~CXMLNode(void)
17      { /* Ne rien faire de plus */ }
18
19      StdString CXMLNode::getElementName(void) const
20      { 
21         return (this->node->name()); 
22      }
23
24      bool CXMLNode::goToNextElement(void)
25      {
26         bool retvalue = false;
27         for(rapidxml::xml_node<char> * nextElement = this->node->next_sibling();
28                                      ; nextElement = this->node->next_sibling())
29         {
30            if (nextElement == NULL) break;
31            else if (nextElement->type() == rapidxml::node_element)
32            { 
33               node = nextElement;
34               return (!retvalue);
35            }
36         }
37         return (retvalue);
38      }
39
40      bool CXMLNode::goToChildElement(void)
41      {
42         bool retvalue = false;
43         rapidxml::xml_node<char> * nextElement = this->node->first_node();
44         if (nextElement != NULL)
45         {
46            for(;;nextElement = this->node->next_sibling())
47            {
48               if (nextElement == NULL) break;
49               else if (nextElement->type() == rapidxml::node_element)
50               { 
51                  node = nextElement;
52                  level++;
53                  return (!retvalue); 
54               }
55            }
56         }
57         return (retvalue);
58      }
59
60      bool CXMLNode::goToParentElement(void)
61      {
62         bool retvalue = false;
63         if (!(this->getElementName().compare(CXMLNode::RootName)) || (level == 0))
64            return (retvalue);
65         node = node->parent();
66         level--;
67         return (!retvalue);
68      }
69
70      bool CXMLNode::getContent(StdString & content)
71      {
72         if (this->node->value_size() == 0) return (false);
73         content.assign(this->node->value(), this->node->value_size());
74         return (true);
75      }
76
77      const StdString & CXMLNode::GetRootName(void)
78      { 
79         return (CXMLNode::RootName); 
80      }
81
82      THashAttributes CXMLNode::getAttributes(void) const
83      {
84         THashAttributes attributes;
85         rapidxml::xml_attribute<char> *currentAttr = NULL;
86
87         if ((currentAttr = this->node->first_attribute()) != NULL)
88         {
89            do 
90            {
91               attributes.insert(std::pair<StdString, StdString>
92                                (StdString(currentAttr->name()),
93                                 StdString(currentAttr->value())));
94            } while ((currentAttr = currentAttr->next_attribute()) != NULL);
95         }
96
97         return (attributes) ;
98      }
99
100   }// namespace xml
101} // namespace xios
Note: See TracBrowser for help on using the repository browser.