Changeset 509 for XIOS/trunk/src/xml_parser.cpp
- Timestamp:
- 11/13/14 15:09:14 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/xml_parser.cpp
r501 r509 13 13 /// ////////////////////// Définitions ////////////////////// /// 14 14 15 void CXMLParser::ParseFile(const StdString & filename )15 void CXMLParser::ParseFile(const StdString & filename, const std::set<StdString>& parseContextList) 16 16 { 17 17 StdIFStream ifs ( filename.c_str() , StdIFStream::in ); … … 20 20 <<endl<< "Can not open <"<<filename<<"> file" ); 21 21 22 CXMLParser::ParseStream(ifs, filename );22 CXMLParser::ParseStream(ifs, filename, parseContextList); 23 23 } 24 24 … … 26 26 { 27 27 StdIStringStream iss ( xmlContent /*, StdIStringStream::in*/ ); 28 CXMLParser::ParseStream(iss,"string"); 28 std::set<StdString> contxtList; 29 CXMLParser::ParseStream(iss,"string", contxtList); 29 30 } 30 31 31 void CXMLParser::ParseStream(StdIStream & stream, const string& fluxId )32 void CXMLParser::ParseStream(StdIStream & stream, const string& fluxId, const std::set<StdString>& parseContextList) 32 33 { 33 34 if (!stream.good()) … … 50 51 << node.getElementName() << "\')!"); 51 52 53 std::set<StdString>::iterator it; 54 std::set<StdString>::const_iterator itE = parseContextList.end(); 55 bool isParseAll = (parseContextList.empty()); 52 56 if (node.goToChildElement()) 53 57 { … … 55 59 { 56 60 CContextGroup* group_context = CContext::getRoot() ; 57 61 58 62 attributes = node.getAttributes(); 59 63 60 64 if (attributes.end() == attributes.find("id")) 61 { 65 { 62 66 DEBUG("The context will not be processed because it is not identified (missing id)"); 63 continue; 67 continue; 64 68 } 65 69 … … 69 73 70 74 if(hasctxt) 71 { 75 { 72 76 DEBUG("The context will not be processed because it exist an other context with the same id" ); 73 continue; 77 continue; 74 78 } 75 79 76 CContext* context = CContext::create(attributes["id"]); 80 if (isParseAll) 81 { 82 CContext* context = CContext::create(attributes["id"]); 77 83 // if (!hasctxt) group_context->addChild(context); 78 context->parse(node);84 context->parse(node); 79 85 80 attributes.clear(); 86 attributes.clear(); 87 } 88 else 89 { 90 it = parseContextList.find(attributes["id"]); 91 if (itE != it) 92 { 93 CContext* context = CContext::create(*it); 94 // if (!hasctxt) group_context->addChild(context); 95 context->parse(node); 81 96 97 attributes.clear(); 98 } 99 } 82 100 } while (node.goToNextElement()); 83 101 } … … 93 111 const char* line; 94 112 const char* endLine; 95 113 96 114 for(const char* i=content;i<content+pos; ++i, ++columnNumber) if (*i=='\n') { lineNumber++ ; line=i ; columnNumber=0 ;} 97 115 for(endLine=content+pos; *endLine!='\n' && *endLine!='\0' ; ++endLine) ; 98 116 string strLine(line,endLine-line) ; 99 117 100 118 ERROR("CXMLParser::ParseStream(StdIStream & stream)", << endl 101 119 << "Error is occuring when parsing XML flux from <"<<fluxId<<"> at character "<< pos<<" line "<<lineNumber<<" column "<< columnNumber<< endl
Note: See TracChangeset
for help on using the changeset viewer.