Ignore:
Timestamp:
09/08/10 15:02:31 (14 years ago)
Author:
hozdoba
Message:

Mise à jour intermédiaire ...
A venir : commit d'une version stable intégrant l'écriture de fichiers NetCDF4.
(en cours de finalisation actuellement)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XMLIO_V2/dev/dev_rv/src/XMLIO/xml_node.hpp

    r117 r120  
    22#define __XMLIO_XML_NODE__ 
    33 
    4 // Entêtes Poco DOM 
    5 #include <Poco/DOM/DOMParser.h> 
    6 #include <Poco/DOM/Document.h> 
    7 #include <Poco/DOM/Element.h> 
    8  
    9 #include <Poco/DOM/NamedNodeMap.h> 
    10  
    11 #include <Poco/DOM/AutoPtr.h> 
    12  
    13 // Entêtes Poco SAX. 
    14 #include <Poco/SAX/InputSource.h> 
    15  
    16 // Utilisation de la STL. 
    17 using std::string; 
    18  
    19 using std::pair; 
    20 using std::vector; 
    21  
    22 using std::istream; 
    23 using std::ostream; 
    24 using std::ostringstream; 
    25 using std::ifstream; 
    26  
    27 // Utilisation de la biliothÚque POCO. 
    28 using Poco::XML::DOMParser; 
    29 using Poco::XML::InputSource; 
    30  
    31 using Poco::XML::Document; 
    32 using Poco::XML::Node; 
    33 using Poco::XML::Element; 
    34  
    35 using Poco::XML::NamedNodeMap; 
    36  
    37 using Poco::HashMap; 
    38  
    39 using Poco::XML::AutoPtr; 
    404 
    415namespace XMLIOSERVER 
     
    437   namespace XML 
    448   { 
    45  
    46       typedef HashMap<string, string> THashAttributes; 
     9      typedef Poco::HashMap<std::string, std::string> THashAttributes; 
    4710 
    4811      class XMLNode 
     
    5013         public : 
    5114 
    52             XMLNode(const string& _rootName) : rootName(_rootName) 
    53             { /* Ne rien faire de plus */} 
    54  
    55             static XMLNode CreateNode(istream& _istr, const string& _rootName) 
     15            static XMLNode CreateNode(std::istream& _istr, const std::string& _rootName) 
    5616            { 
    5717               XMLNode node(_rootName); 
     18 
    5819               if (_istr.good()) 
    5920               { // S'il est possible de lire le flux en entrée ... 
    60                   InputSource src(_istr); 
    61                   DOMParser parser; 
     21 
     22                  Poco::XML::InputSource src(_istr); 
     23                  Poco::XML::DOMParser parser; 
    6224 
    6325                  node.pDoc = parser.parse(&src); 
    6426                  node.setCNode(node.pDoc->documentElement()); 
    65                   if (node.getElementName().compare(_rootName) != 0) 
     27                  if (node.getElementName().compare(_rootName) != 0) // << A passer en avertissement. 
    6628                     throw XMLParsingException("L'élément racine doit avoir pour valeur <" + _rootName + "> (\"" + node.getElementName() + "\" lue)"); 
    6729               } 
     
    7335 
    7436            string getElementName(void) const 
    75             { string _str(this->getCNode()->nodeName()); return (_toLower(_str)); } 
     37            { 
     38               std::string _str(this->getCNode()->nodeName()); 
     39               return (_toLower(_str)); 
     40            } 
    7641 
    7742            bool goToNextElement(void) 
    7843            { 
    79                Node* nextElement = this->getCNode()->nextSibling(); 
     44               Poco::XML::Node* nextElement = this->getCNode()->nextSibling(); 
    8045 
    8146               // On parcourt la liste des "siblings" jusqu'à trouver un élément quelconque. 
     
    9257            bool goToChildElement(void) 
    9358            { 
    94                Node* nextElement = this->getCNode()->firstChild(); 
     59               Poco::XML::Node* nextElement = this->getCNode()->firstChild(); 
    9560 
    9661               // On parcourt la liste des enfants jusqu'à trouver un élément quelconque. 
     
    9863               { 
    9964                  for(; ; nextElement = nextElement->nextSibling()) 
    100                      if (IsPtrNull(nextElement)) break; 
     65                     if (IsPtrNull(nextElement)) return (false); 
    10166                     else if (nextElement->nodeType() == 1) 
    10267                     {// Si l'un des noeuds est un élément... 
     
    10469                        return (true); 
    10570                     } 
    106                   return (false); 
    10771               } 
    108  
    10972               return (false); 
    11073            } 
     
    11881            } 
    11982 
    120             bool getAttributes(THashAttributes& attributes) const 
     83            bool getAttributes(THashAttributes& _attributes) const 
    12184            { 
    12285               if(!this->getCNode()->hasAttributes()) return (false); 
    123                AutoPtr<NamedNodeMap> map = this->getCNode()->attributes(); 
     86               Poco::XML::AutoPtr<Poco::XML::NamedNodeMap> map = this->getCNode()->attributes(); 
    12487 
    12588               for(unsigned int i = 0; i< map->length(); i++) 
    12689               { // Suppression des espaces en début et fin de valeur d'attribut xml. 
    127                   string _str(map->item(i)->nodeName()); 
     90                  std::string _str(map->item(i)->nodeName()); 
    12891                  size_t d = map->item(i)->nodeValue().find_first_not_of(' '); 
    12992                  size_t f = map->item(i)->nodeValue().find_last_not_of (' '); 
    130                   attributes[_toLower(_str)] = map->item(i)->nodeValue().substr(d,f-d+1); 
     93 
     94                  _attributes[_toLower(_str)] = map->item(i)->nodeValue().substr(d,f-d+1); 
    13195               } 
    13296               return (true); 
     
    138102         protected : 
    139103 
    140             Node* getCNode(void) const { return (this->cNode); } 
    141             void setCNode(Node* other) { this->cNode = other; } 
     104            Poco::XML::Node * getCNode(void) const { return (this->cNode); } 
     105            void setCNode(Poco::XML::Node * _otherNode) { this->cNode = _otherNode; } 
    142106 
    143             static bool IsPtrNull(Node* ptr) { return (ptr==NULL); } 
     107            static bool IsPtrNull(const Poco::XML::Node * const _ptr) { return (_ptr == NULL); } 
    144108 
    145109         private : 
    146110 
    147             const string& _toLower(string& _str) const 
     111            XMLNode(const std::string& _rootName) : rootName(_rootName) 
     112            { /* Ne rien faire de plus */} 
     113 
     114            const string& _toLower(std::string& _str) const 
    148115            { 
    149116               for (unsigned int i = 0; i < _str.size(); i++) 
     
    152119            } 
    153120 
    154             AutoPtr<Document> pDoc; 
    155             Node*  cNode; 
     121            Poco::XML::AutoPtr<Poco::XML::Document> pDoc; 
     122            Poco::XML::Node*  cNode; 
    156123 
    157124            string rootName; 
Note: See TracChangeset for help on using the changeset viewer.