New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
group_parser.hpp in vendors/XIOS/current/src – NEMO

source: vendors/XIOS/current/src/group_parser.hpp @ 3428

Last change on this file since 3428 was 3428, checked in by rblod, 12 years ago

importing initial XIOS vendor drop

File size: 2.8 KB
Line 
1#ifndef __XMLIO_GroupParser__
2#define __XMLIO_GroupParser__
3
4/// boost headers ///
5#include <boost/cast.hpp>
6
7namespace xios
8{
9   /// ////////////////////// Définitions ////////////////////// ///
10   template <class U, class V, class W>
11      void CGroupTemplate<U, V, W>::parse(xml::CXMLNode & node, bool withAttr)
12   {
13
14      StdString name = node.getElementName();
15      xml::THashAttributes attributes = node.getAttributes();
16      if (withAttr)
17      {
18         CGroupTemplate<U, V, W>::SuperClass::parse(node);
19         if (attributes.end() != attributes.find("src"))
20         {
21            StdIFStream ifs ( attributes["src"].c_str() , StdIFStream::in );
22            if (!ifs.good())
23               ERROR("CGroupTemplate<U, V, W>::parse(xml::CXMLNode & node, bool withAttr)",
24                     << "[ filename = " << attributes["src"] << " ] Bad xml stream !");
25            xml::CXMLParser::ParseInclude(ifs, *this);
26         }
27      }
28
29      // PARSING POUR GESTION DES ENFANTS
30           V* group_ptr = (this->hasId()) 
31         ? V::get(this->getId())
32         : boost::polymorphic_downcast<V*>(this);
33
34      if (!(node.goToChildElement()))
35      {
36         if (this->hasId())
37         {
38            DEBUG(<< "L'objet de type \'" << V::GetName()
39                  << "\' nommé \'" << this->getId()
40                  << "\' ne contient pas d\'enfant !");
41         }
42      }
43      else
44      {
45         do { // Parcours pour traitement.
46
47            StdString name = node.getElementName();
48            attributes.clear();
49            attributes = node.getAttributes();
50
51            if (name.compare(V::GetName()) == 0)
52            {
53               if (attributes.end() == attributes.find("id"))
54                  CGroupFactory::CreateGroup(group_ptr->getShared())->parse(node);
55               else
56                  CGroupFactory::CreateGroup(group_ptr->getShared(), attributes["id"])->parse(node);
57               continue;
58            }
59
60            if (name.compare(U::GetName()) == 0)
61            {
62               if (attributes.end() == attributes.find("id"))
63                  CGroupFactory::CreateChild(group_ptr->getShared())->parse(node);
64               else
65                  CGroupFactory::CreateChild(group_ptr->getShared(), attributes["id"])->parse(node);
66               continue;
67            }
68
69            DEBUG(<< "Dans le contexte \'" << CContext::getCurrent()->getId()
70                  << "\', un objet de type \'" << V::GetName()
71                  << "\' ne peut contenir qu'un objet de type \'" << V::GetName()
72                  << "\' ou de type \'" << U::GetName()
73                  << "\' (reçu : " << name << ") !");
74
75         } while (node.goToNextElement());
76         node.goToParentElement(); // Retour au parent
77      }
78   }
79
80} // namespace xios
81
82#endif // __XMLIO_GroupParser__
Note: See TracBrowser for help on using the repository browser.