Ignore:
Timestamp:
03/12/24 20:09:55 (4 months ago)
Author:
ymipsl
Message:
  • Permit now usage of contex_group into xml file for more modularity
  • Src path is now relative to parent file, except if path is an absolute path

YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS2/trunk/src/node/context.cpp

    r2428 r2615  
    113113      xml::THashAttributes attributes = node.getAttributes(); 
    114114 
    115       if (attributes.end() != attributes.find("src")) 
    116       { 
    117          StdIFStream ifs ( attributes["src"].c_str() , StdIFStream::in ); 
    118          if ( (ifs.rdstate() & std::ifstream::failbit ) != 0 ) 
    119             ERROR("void CContext::parse(xml::CXMLNode & node)", 
    120                   <<endl<< "Can not open <"<<attributes["src"].c_str()<<"> file" ); 
    121          if (!ifs.good()) 
    122             ERROR("CContext::parse(xml::CXMLNode & node)", 
    123                   << "[ filename = " << attributes["src"] << " ] Bad xml stream !"); 
    124          xml::CXMLParser::ParseInclude(ifs, attributes["src"], *this); 
    125       } 
     115      if (attributes.end() != attributes.find("src")) xml::CXMLParser::ParseInclude(attributes["src"], *this); 
    126116 
    127117      if (node.getElementName().compare(CContext::GetName())) 
     
    162152   } 
    163153   CATCH_DUMP_ATTR 
     154 
     155   template <> 
     156   void CGroupTemplate<CContext, CContextGroup, CContextAttributes>::parse(xml::CXMLNode & node, bool withAttr, const std::set<StdString>& parseContextList) 
     157   TRY 
     158   { 
     159      StdString name = node.getElementName(); 
     160      xml::THashAttributes attributes = node.getAttributes(); 
     161      CGroupTemplate<CContext, CContextGroup, CContextAttributes>::SuperClass::parse(node); 
     162      if (attributes.end() != attributes.find("src")) xml::CXMLParser::ParseInclude(attributes["src"].c_str(), *this, parseContextList); 
     163 
     164      if (!(node.goToChildElement())) 
     165      { 
     166        // no children ? 
     167      } 
     168      else 
     169      { 
     170        do // Parcours pour traitement. 
     171        {  
     172 
     173          StdString name = node.getElementName(); 
     174          attributes.clear(); 
     175          attributes = node.getAttributes(); 
     176 
     177          if (name.compare(CContextGroup::GetName()) == 0) 
     178          { 
     179            CContextGroup contextGroup ; 
     180            contextGroup.parse(node, true, parseContextList) ; 
     181            continue; 
     182          } 
     183 
     184          if (name.compare(CContext::GetName()) == 0) 
     185          { 
     186            if (attributes.end() == attributes.find("id")) 
     187            { 
     188              DEBUG("The context will not be processed because it is not identified (missing id)"); 
     189              continue; 
     190            } 
     191            else 
     192            {   
     193              if (parseContextList.empty() || parseContextList.count(attributes["id"]) > 0) 
     194              { 
     195                CContext::setCurrent(attributes["id"]) ; 
     196                CContext* context = CContext::create(attributes["id"]); 
     197                context->parse(node); 
     198                attributes.clear(); 
     199              } 
     200              continue; 
     201            } 
     202          } 
     203 
     204          DEBUG(<< "Dans le contexte \'" << CContext::getCurrent()->getId() 
     205                << "\', un objet de type \'" << CContextGroup::GetName() 
     206                << "\' ne peut contenir qu'un objet de type \'" << CContextGroup::GetName() 
     207                << "\' ou de type \'" << CContext::GetName() 
     208                << "\' (reçu : " << name << ") !"); 
     209 
     210         } while (node.goToNextElement()); 
     211         node.goToParentElement(); // Retour au parent 
     212      } 
     213   } 
     214   CATCH_DUMP_ATTR 
     215 
     216 
     217 
    164218 
    165219   //---------------------------------------------------------------- 
Note: See TracChangeset for help on using the changeset viewer.