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

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

Réorganisation du code source (suppression des préfixes xmlio_ redondants)
Simplification de la gestion des groupes (ajout d'une macro dans le fichier d'entête declare_group.hpp).

File size: 1.5 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                  context.parse(_node);
40                  attributes.clear();
41
42               } while (_node.goToNextElement());
43            }
44      }; // class XMLParser
45   }; // namespace XML
46
47};// namespace XMLIOSERVER
48
49
50#endif // __XMLIO_XML_PARSER__
Note: See TracBrowser for help on using the repository browser.