source: XMLIO_V2/dev/dev_rv/src/XMLIO/xml_parser.hpp @ 125

Last change on this file since 125 was 125, checked in by hozdoba, 14 years ago
File size: 1.8 KB
Line 
1#ifndef __XMLIO_XML_PARSER__
2#define __XMLIO_XML_PARSER__
3
4#include <stdlib.h>
5
6// Utilisation de la STL
7using std::string;
8
9namespace XMLIOSERVER
10{
11   namespace XML
12   {
13      using XMLIOSERVER::Context;
14
15      class XMLParser
16      {
17         public :
18
19            static void Parse(XMLNode& _node)
20            {
21               THashAttributes attributes;
22
23               _node.goToChildElement(); // On se place sur le premier élément enfant du noeud racine.
24               atexit (&Context::FreeMemory); // Pour supprimer la mémoire liée à l'allocation dynamique en fin d'exécution du programme.
25
26               do {
27                 // Traitement de l'identifiant
28                  _node.getAttributes(attributes);
29
30                  if (attributes.end() == attributes.find("id"))
31                  { WARNING("Le context ne sera pas traité car il n'est pas identifié !"); continue; }
32
33                  if( Context::GetAllListObject().find(attributes["id"]) != Context::GetAllListObject().end())
34                  { WARNING("Le context ne sera pas traité car il existe déjà un autre context possédant le même nom !"); continue; }
35
36                  Context::SetCurrentContext(attributes["id"]);
37                  Context& context = *Context::CreateObject(attributes["id"]);
38
39                  if ((attributes.end() != attributes.find("calendar_type")) &&
40                      (attributes.end() != attributes.find("start_date")))
41                     context.setCalendar(attributes["calendar_type"], attributes["start_date"]);
42
43                  context.parse(_node);
44                  attributes.clear();
45
46               } while (_node.goToNextElement());
47            }
48      }; // class XMLParser
49   } // namespace XML
50
51}// namespace XMLIOSERVER
52
53
54#endif // __XMLIO_XML_PARSER__
Note: See TracBrowser for help on using the repository browser.