Ignore:
Timestamp:
03/12/24 20:02:35 (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
  • XIOS3/trunk/src/xml_parser.cpp

    r1622 r2614  
    1111   namespace xml 
    1212   { 
     13      string CXMLParser::currentIncludePath_="." ; 
     14 
     15      string CXMLParser::updateIncludePath(const string& filePath) 
     16      { 
     17        string path = strTrim(filePath) ; 
     18        vector<string> match=splitRegex(path+'/',"/" ) ; 
     19 
     20        // check if empty path 
     21        bool isEmpty=true ; 
     22        for(auto& m : match)  
     23          if (!m.empty()) 
     24          { 
     25            isEmpty=false ; 
     26            break ; 
     27          } 
     28 
     29        if (isEmpty) ERROR("string CXMLParser::updatePath(const string& filePath)", 
     30                     << "File path to include an new XML is empty :'"<<filePath<<"'" ); 
     31 
     32        if (match.back().empty()) ERROR("string CXMLParser::updatePath(const string& filePath)", 
     33                     << "File path to include an new XML must not be a directory but a file :'"<<filePath<<"'" ); 
     34        bool isAbsolutePath = match.front().empty() ; 
     35         
     36        if (isAbsolutePath) currentIncludePath_="" ; 
     37        for(int i=0; i<match.size()-1; ++i) if (! match[i].empty()) currentIncludePath_ = currentIncludePath_ + "/" + match[i] ; 
     38         
     39        string finalPath = currentIncludePath_ + "/" + match.back() ; 
     40 
     41        return finalPath ; 
     42      } 
     43 
    1344      /// ////////////////////// Définitions ////////////////////// /// 
    1445 
     
    5283                     << "Root element should be named simulation (actual = \'" 
    5384                     << node.getElementName() << "\')!"); 
    54  
    55             std::set<StdString>::iterator it; 
    56             std::set<StdString>::const_iterator itE = parseContextList.end(); 
    57             bool isParseAll = (parseContextList.empty()); 
    5885            try 
    5986            { 
    60               if (node.goToChildElement()) 
    61               { 
    62                  do 
    63                  { 
    64                     CContextGroup* group_context = CContext::getRoot() ; 
    65  
    66                     attributes = node.getAttributes(); 
    67  
    68                     if (attributes.end() == attributes.find("id")) 
    69                     { 
    70                        DEBUG("The context will not be processed because it is not identified (missing id)"); 
    71                        continue; 
    72                     } 
    73  
    74                     CContext::setCurrent(attributes["id"]) ; 
    75  
    76                     if (isParseAll) 
    77                     { 
    78                       CContext* context = CContext::create(attributes["id"]); 
    79                       context->parse(node); 
    80  
    81                       attributes.clear(); 
    82                     } 
    83                     else 
    84                     { 
    85                       it = parseContextList.find(attributes["id"]); 
    86                       if (itE != it) 
    87                       { 
    88                         CContext* context = CContext::create(*it); 
    89                         context->parse(node); 
    90  
    91                         attributes.clear(); 
    92                       } 
    93                     } 
    94                  } while (node.goToNextElement()); 
    95               } 
     87              CContextGroup* rootContext = CContext::getRoot() ; 
     88              rootContext->parse(node, true, parseContextList) ; 
    9689            } 
    9790            catch(CException& e) 
Note: See TracChangeset for help on using the changeset viewer.