Last change
on this file since 2328 was
1622,
checked in by oabramkina, 6 years ago
|
Exception handling on trunk.
To activate it, compilation flag -DXIOS_EXCEPTION should be added.
|
-
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.6 KB
|
Rev | Line | |
---|
[591] | 1 | #ifndef __XIOS_CXMLParser__ |
---|
| 2 | #define __XIOS_CXMLParser__ |
---|
[219] | 3 | |
---|
[591] | 4 | /// XIOS headers /// |
---|
| 5 | #include "xios_spl.hpp" |
---|
[278] | 6 | #include "exception.hpp" |
---|
[1622] | 7 | #include "cxios.hpp" |
---|
[219] | 8 | #include "xml_node.hpp" |
---|
| 9 | |
---|
[278] | 10 | |
---|
[335] | 11 | namespace xios |
---|
[219] | 12 | { |
---|
| 13 | namespace xml |
---|
| 14 | { |
---|
| 15 | /// ////////////////////// Déclarations ////////////////////// /// |
---|
| 16 | class CXMLParser |
---|
| 17 | { |
---|
| 18 | public : |
---|
| 19 | |
---|
[509] | 20 | static void ParseFile(const StdString & filename, const std::set<StdString>& parseList = std::set<StdString>()); |
---|
[219] | 21 | static void ParseString(const StdString & xmlContent); |
---|
[509] | 22 | static void ParseStream(StdIStream & stream, const string& fluxId, const std::set<StdString>& parseList); |
---|
[278] | 23 | template <class T> |
---|
[462] | 24 | static void ParseInclude(StdIStream & stream, const string& fluxId, T & object); |
---|
[219] | 25 | |
---|
| 26 | }; //class CXMLParser |
---|
[352] | 27 | /* |
---|
[278] | 28 | template <class T> |
---|
| 29 | void CXMLParser::ParseInclude(StdIStream & stream, T& object) |
---|
| 30 | { |
---|
| 31 | StdOStringStream oss; |
---|
| 32 | while(!stream.eof() && !stream.fail ()) |
---|
| 33 | oss.put(stream.get()); |
---|
| 34 | try |
---|
| 35 | { |
---|
| 36 | const StdString xmlcontent( oss.str(), 0, oss.str().size()-1 ); |
---|
| 37 | rapidxml::xml_document<char> doc; |
---|
| 38 | doc.parse<0>(const_cast<char*>(xmlcontent.c_str())); |
---|
| 39 | CXMLNode node(doc.first_node()); |
---|
| 40 | object.parse(node); |
---|
| 41 | } |
---|
| 42 | catch (rapidxml::parse_error & exc) |
---|
| 43 | { |
---|
| 44 | ERROR("CXMLParser::ParseStream(StdIStream & stream)", |
---|
| 45 | << "RapidXML error : " << exc.what() << " !"); |
---|
| 46 | } |
---|
| 47 | } |
---|
[352] | 48 | */ |
---|
[219] | 49 | }// namespace xml |
---|
[335] | 50 | } // namespace xios |
---|
[219] | 51 | |
---|
[591] | 52 | #endif // __XIOS_CXMLParser__ |
---|
Note: See
TracBrowser
for help on using the repository browser.