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

Last change on this file since 132 was 132, checked in by hozdoba, 14 years ago

suite interface cpp<->fortran

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"]) !=
34                      Context::GetAllListObject().end())
35                  { WARNING("Le context ne sera pas traité car il existe déjà un autre context possédant le même nom !"); continue; }
36
37                  Context::SetCurrentContext(attributes["id"], false, false);
38                  Context& context = *Context::CreateObject(attributes["id"]);
39
40                  if ((attributes.end() != attributes.find("calendar_type")) &&
41                      (attributes.end() != attributes.find("start_date")))
42                     context.setCalendar(attributes["calendar_type"], attributes["start_date"]);
43
44                  context.parse(_node);
45                  attributes.clear();
46
47               } while (_node.goToNextElement());
48            }
49
50      }; // class XMLParser
51   } // namespace XML
52
53}// namespace XMLIOSERVER
54
55
56#endif // __XMLIO_XML_PARSER__
Note: See TracBrowser for help on using the repository browser.