Last change
on this file since 2219 was
591,
checked in by rlacroix, 9 years ago
|
Remove leftovers from the XMLIO age.
|
-
Property copyright set to
Software name : XIOS (Xml I/O Server) http://forge.ipsl.jussieu.fr/ioserver Creation date : January 2009 Licence : CeCCIL version2 see license file in root directory : Licence_CeCILL_V2-en.txt or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement) CNRS/IPSL (Institut Pierre Simon Laplace) Project Manager : Yann Meurdesoif yann.meurdesoif@cea.fr
|
File size:
1.8 KB
|
Line | |
---|
1 | #ifndef __XIOS_CXML_PARSER_IMPL__ |
---|
2 | #define __XIOS_CXML_PARSER_IMPL__ |
---|
3 | |
---|
4 | /// XIOS headers /// |
---|
5 | #include "xml_parser.hpp" |
---|
6 | |
---|
7 | namespace xios |
---|
8 | { |
---|
9 | namespace xml |
---|
10 | { |
---|
11 | template <class T> void CXMLParser::ParseInclude(StdIStream & stream, const string& fluxId, T& object) |
---|
12 | { |
---|
13 | StdOStringStream oss; |
---|
14 | while(!stream.eof() && !stream.fail ()) oss.put(stream.get()); |
---|
15 | const StdString xmlcontent( oss.str(), 0, oss.str().size()-1 ); |
---|
16 | try |
---|
17 | { |
---|
18 | rapidxml::xml_document<char> doc; |
---|
19 | doc.parse<0>(const_cast<char*>(xmlcontent.c_str())); |
---|
20 | CXMLNode node(doc.first_node()); |
---|
21 | object.parse(node); |
---|
22 | } |
---|
23 | catch (rapidxml::parse_error & exc) |
---|
24 | { |
---|
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() ) |
---|
43 | } |
---|
44 | } |
---|
45 | |
---|
46 | } // namespace xml |
---|
47 | } // namespace xios |
---|
48 | |
---|
49 | #endif // __XIOS_CXML_PARSER_IMPL__ |
---|
50 | |
---|
Note: See
TracBrowser
for help on using the repository browser.