Rev | Line | |
---|
[112] | 1 | #ifndef __XMLIO_XML_PARSER__ |
---|
| 2 | #define __XMLIO_XML_PARSER__ |
---|
| 3 | |
---|
| 4 | #include <stdlib.h> |
---|
| 5 | |
---|
| 6 | // Utilisation de la STL |
---|
| 7 | using std::string; |
---|
| 8 | |
---|
| 9 | namespace 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 | |
---|
[127] | 33 | if( Context::GetAllListObject().find(attributes["id"]) != |
---|
| 34 | Context::GetAllListObject().end()) |
---|
[112] | 35 | { WARNING("Le context ne sera pas traité car il existe déjà un autre context possédant le même nom !"); continue; } |
---|
| 36 | |
---|
[132] | 37 | Context::SetCurrentContext(attributes["id"], false, false); |
---|
[120] | 38 | Context& context = *Context::CreateObject(attributes["id"]); |
---|
[112] | 39 | |
---|
[125] | 40 | if ((attributes.end() != attributes.find("calendar_type")) && |
---|
| 41 | (attributes.end() != attributes.find("start_date"))) |
---|
[123] | 42 | context.setCalendar(attributes["calendar_type"], attributes["start_date"]); |
---|
| 43 | |
---|
[112] | 44 | context.parse(_node); |
---|
| 45 | attributes.clear(); |
---|
| 46 | |
---|
| 47 | } while (_node.goToNextElement()); |
---|
| 48 | } |
---|
[127] | 49 | |
---|
[112] | 50 | }; // class XMLParser |
---|
[114] | 51 | } // namespace XML |
---|
[112] | 52 | |
---|
[114] | 53 | }// namespace XMLIOSERVER |
---|
[112] | 54 | |
---|
| 55 | |
---|
| 56 | #endif // __XMLIO_XML_PARSER__ |
---|
Note: See
TracBrowser
for help on using the repository browser.