- Timestamp:
- 01/21/14 09:40:14 (10 years ago)
- Location:
- XIOS/trunk
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/bld.cfg
r452 r462 30 30 bld::lib xios 31 31 bld::target libxios.a 32 #bld::target test.exe 33 bld::target generate_fortran_interface.exe 34 bld::target xios_server.exe test_cs.exe test_client.exe test_unstruct.exe 32 #bld::target generate_fortran_interface.exe 33 bld::target xios_server.exe test_client.exe parse_xml.exe 35 34 bld::exe_dep 36 35 -
XIOS/trunk/src/group_parser.hpp
r347 r462 20 20 { 21 21 StdIFStream ifs ( attributes["src"].c_str() , StdIFStream::in ); 22 if ( (ifs.rdstate() & std::ifstream::failbit ) != 0 ) 23 ERROR(" void CGroupTemplate<U, V, W>::parse(xml::CXMLNode & node, bool withAttr)", 24 <<endl<< "Can not open <"<<attributes["src"].c_str()<<"> file" ); 22 25 if (!ifs.good()) 23 26 ERROR("CGroupTemplate<U, V, W>::parse(xml::CXMLNode & node, bool withAttr)", 24 27 << "[ filename = " << attributes["src"] << " ] Bad xml stream !"); 25 xml::CXMLParser::ParseInclude(ifs, *this);28 xml::CXMLParser::ParseInclude(ifs, attributes["src"].c_str(), *this); 26 29 } 27 30 } -
XIOS/trunk/src/group_template_impl.hpp
r446 r462 490 490 { 491 491 StdIFStream ifs ( attributes["src"].c_str() , StdIFStream::in ); 492 if ( (ifs.rdstate() & std::ifstream::failbit ) != 0 ) 493 ERROR("void CGroupTemplate<U, V, W>::parse(xml::CXMLNode & node, bool withAttr)", 494 <<endl<< "Can not open <"<<attributes["src"].c_str()<<"> file" ); 495 492 496 if (!ifs.good()) 493 497 ERROR("CGroupTemplate<U, V, W>::parse(xml::CXMLNode & node, bool withAttr)", 494 498 << "[ filename = " << attributes["src"] << " ] Bad xml stream !"); 495 xml::CXMLParser::ParseInclude(ifs, *this);499 xml::CXMLParser::ParseInclude(ifs, attributes["src"].c_str(), *this); 496 500 } 497 501 } -
XIOS/trunk/src/node/context.cpp
r461 r462 110 110 { 111 111 StdIFStream ifs ( attributes["src"].c_str() , StdIFStream::in ); 112 if ( (ifs.rdstate() & std::ifstream::failbit ) != 0 ) 113 ERROR("void CContext::parse(xml::CXMLNode & node)", 114 <<endl<< "Can not open <"<<attributes["src"].c_str()<<"> file" ); 112 115 if (!ifs.good()) 113 116 ERROR("CContext::parse(xml::CXMLNode & node)", 114 117 << "[ filename = " << attributes["src"] << " ] Bad xml stream !"); 115 xml::CXMLParser::ParseInclude(ifs, *this);118 xml::CXMLParser::ParseInclude(ifs, attributes["src"], *this); 116 119 } 117 120 -
XIOS/trunk/src/xml_parser.cpp
r352 r462 16 16 { 17 17 StdIFStream ifs ( filename.c_str() , StdIFStream::in ); 18 CXMLParser::ParseStream(ifs); 18 if ( (ifs.rdstate() & std::ifstream::failbit ) != 0 ) 19 ERROR("void CXMLParser::ParseFile(const StdString & filename)", 20 <<endl<< "Can not open <"<<filename<<"> file" ); 21 22 CXMLParser::ParseStream(ifs, filename); 19 23 } 20 24 … … 22 26 { 23 27 StdIStringStream iss ( xmlContent /*, StdIStringStream::in*/ ); 24 CXMLParser::ParseStream(iss );28 CXMLParser::ParseStream(iss,"string"); 25 29 } 26 30 27 void CXMLParser::ParseStream(StdIStream & stream )31 void CXMLParser::ParseStream(StdIStream & stream, const string& fluxId) 28 32 { 29 33 if (!stream.good()) … … 31 35 << "Bad xml stream !"); 32 36 StdOStringStream oss; 33 while(!stream.eof() && !stream.fail ()) 34 oss.put(stream.get());37 while(!stream.eof() && !stream.fail ()) oss.put(stream.get()); 38 const StdString xmlcontent( oss.str(), 0, oss.str().size()-1 ); 35 39 try 36 40 { 37 //const StdString xmlcontent( oss.str(), 0, oss.str().size()-2); //<POURQUOI ?38 const StdString xmlcontent( oss.str(), 0, oss.str().size()-1 );39 41 rapidxml::xml_document<char> doc; 40 42 doc.parse<0>(const_cast<char*>(xmlcontent.c_str())); … … 58 60 if (attributes.end() == attributes.find("id")) 59 61 { 60 DEBUG(" Le context ne sera pas traité car il n'est pas identifié !");62 DEBUG("The context will not be processed because it is not identified (missing id)"); 61 63 continue; 62 64 } … … 68 70 if(hasctxt) 69 71 { 70 DEBUG("Le context ne sera pas traité car " 71 << "il existe déjà un autre context possédant le même nom !"); 72 DEBUG("The context will not be processed because it exist an other context with the same id" ); 72 73 continue; 73 74 } … … 84 85 catch (rapidxml::parse_error & exc) 85 86 { 86 ERROR("CXMLParser::ParseStream(StdIStream & stream)", 87 << "RapidXML error : " << exc.what() << " !"); 87 const char* ptr = exc.where<char>() ; 88 const char* begin = xmlcontent.c_str() ; 89 const char* content=oss.str().c_str() ; 90 size_t pos=ptr-begin ; 91 int lineNumber = 1 ; 92 int columnNumber = 0 ; 93 const char* line; 94 const char* endLine; 95 96 for(const char* i=content;i<content+pos; ++i, ++columnNumber) if (*i=='\n') { lineNumber++ ; line=i ; columnNumber=0 ;} 97 for(endLine=content+pos; *endLine!='\n' && *endLine!='\0' ; ++endLine) ; 98 string strLine(line,endLine-line) ; 99 100 ERROR("CXMLParser::ParseStream(StdIStream & stream)", << endl 101 << "Error is occuring when parsing XML flux from <"<<fluxId<<"> at character "<< pos<<" line "<<lineNumber<<" column "<< columnNumber<< endl 102 << strLine<<endl 103 << string(columnNumber-1,'x')<<'^'<<endl 104 <<" Error : " << exc.what() ) 88 105 } 89 106 } -
XIOS/trunk/src/xml_parser.hpp
r352 r462 19 19 static void ParseFile(const StdString & filename); 20 20 static void ParseString(const StdString & xmlContent); 21 static void ParseStream(StdIStream & stream );21 static void ParseStream(StdIStream & stream, const string& fluxId); 22 22 template <class T> 23 static void ParseInclude(StdIStream & stream, T & object);23 static void ParseInclude(StdIStream & stream, const string& fluxId, T & object); 24 24 25 25 }; //class CXMLParser -
XIOS/trunk/src/xml_parser_decl.cpp
r352 r462 13 13 namespace xml 14 14 { 15 template void CXMLParser::ParseInclude<CContext>(StdIStream & stream, CContext& object) ;15 template void CXMLParser::ParseInclude<CContext>(StdIStream & stream, const string& fluxId, CContext& object) ; 16 16 17 17 # define macro(T) \ 18 template void CXMLParser::ParseInclude< CGroupTemplate<C##T, C##T##Group, C##T##Attributes> >(StdIStream & stream, CGroupTemplate<C##T, C##T##Group, C##T##Attributes>& object) ;18 template void CXMLParser::ParseInclude< CGroupTemplate<C##T, C##T##Group, C##T##Attributes> >(StdIStream & stream, const string& fluxId, CGroupTemplate<C##T, C##T##Group, C##T##Attributes>& object) ; 19 19 20 20 macro( Context ) -
XIOS/trunk/src/xml_parser_impl.hpp
r352 r462 9 9 namespace xml 10 10 { 11 template <class T> void CXMLParser::ParseInclude(StdIStream & stream, T& object)11 template <class T> void CXMLParser::ParseInclude(StdIStream & stream, const string& fluxId, T& object) 12 12 { 13 13 StdOStringStream oss; 14 while(!stream.eof() && !stream.fail ()) 15 oss.put(stream.get());14 while(!stream.eof() && !stream.fail ()) oss.put(stream.get()); 15 const StdString xmlcontent( oss.str(), 0, oss.str().size()-1 ); 16 16 try 17 17 { 18 const StdString xmlcontent( oss.str(), 0, oss.str().size()-1 );19 18 rapidxml::xml_document<char> doc; 20 19 doc.parse<0>(const_cast<char*>(xmlcontent.c_str())); … … 24 23 catch (rapidxml::parse_error & exc) 25 24 { 26 ERROR("CXMLParser::ParseStream(StdIStream & stream)", 27 << "RapidXML error : " << exc.what() << " !"); 25 const char* ptr = exc.where<char>() ; 26 const char* begin = xmlcontent.c_str() ; 27 const char* content=oss.str().c_str() ; 28 size_t pos=ptr-begin ; 29 int lineNumber = 1 ; 30 int columnNumber = 0 ; 31 const char* line; 32 const char* endLine; 33 34 for(const char* i=content;i<content+pos; ++i, ++columnNumber) if (*i=='\n') { lineNumber++ ; line=i ; columnNumber=0 ;} 35 for(endLine=content+pos; *endLine!='\n' && *endLine!='\0' ; ++endLine) ; 36 string strLine(line,endLine-line) ; 37 38 ERROR("CXMLParser::ParseStream(StdIStream & stream)", << endl 39 << "Error is occuring when parsing XML flux from <"<<fluxId<<"> at character "<< pos<<" line "<<lineNumber<<" column "<< columnNumber<< endl 40 << strLine<<endl 41 << string(columnNumber-1,'x')<<'^'<<endl 42 <<" Error : " << exc.what() ) 28 43 } 29 44 }
Note: See TracChangeset
for help on using the changeset viewer.