$treeview $search $mathjax
|
Palabos
Version 1.1
$projectbrief
|
$projectbrief
|
$searchbox |
00001 /* This file is part of the Palabos library. 00002 * 00003 * Copyright (C) 2011 FlowKit Sarl 00004 * Avenue de Chailly 23 00005 * 1012 Lausanne, Switzerland 00006 * E-mail contact: contact@flowkit.com 00007 * 00008 * The most recent release of Palabos can be downloaded at 00009 * <http://www.palabos.org/> 00010 * 00011 * The library Palabos is free software: you can redistribute it and/or 00012 * modify it under the terms of the GNU Affero General Public License as 00013 * published by the Free Software Foundation, either version 3 of the 00014 * License, or (at your option) any later version. 00015 * 00016 * The library is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Affero General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Affero General Public License 00022 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00023 */ 00024 00029 #ifndef XML_IO_H 00030 #define XML_IO_H 00031 00032 #include <string> 00033 #include <vector> 00034 #include <map> 00035 #include "tinyxml/tinyxml.h" 00036 #include "core/array.h" 00037 00038 namespace plb { 00039 00040 class XMLreaderProxy; 00041 00042 class XMLreader { 00043 public: 00044 XMLreader( std::string fName ); 00045 XMLreader( std::vector<TiXmlNode*> pParentVect ); 00046 ~XMLreader(); 00047 void print(int indent) const; 00048 XMLreaderProxy operator[] (std::string name) const; 00049 XMLreaderProxy getElement(std::string name, plint id) const; 00050 std::string getName() const; 00051 std::string getText() const; 00052 std::string getText(plint id) const; 00053 plint getFirstId() const; 00054 std::string getFirstText() const; 00055 bool idExists(plint id) const; 00056 bool getNextId(plint& id) const; 00057 std::vector<XMLreader*> const& getChildren(plint id) const; 00058 private: 00059 void mainProcessorIni(TiXmlNode* pParent); 00060 void mainProcessorIni(std::vector<TiXmlNode*> pParentVect); 00061 void slaveProcessorIni(); 00062 XMLreader(); 00063 private: 00064 struct Data { 00065 std::string text; 00066 std::vector<XMLreader*> children; 00067 }; 00068 private: 00069 std::string name; 00070 std::map<plint,Data> data_map; 00071 static XMLreader notFound; 00072 }; 00073 00074 class XMLreaderProxy { 00075 public: 00076 XMLreaderProxy(XMLreader const* reader_); 00077 XMLreaderProxy(XMLreader const* reader_, plint id_); 00078 template <typename T> void read(T& values) const; 00079 template <typename T> bool readNoThrow(T& values) const; 00080 template <typename T> void read(std::vector<T>& values) const; 00081 template <typename T> bool readNoThrow(std::vector<T>& values) const; 00082 template <typename T, plint N> void read(Array<T,N>& values) const; 00083 template <typename T, plint N> bool readNoThrow(Array<T,N>& values) const; 00084 XMLreaderProxy operator[] (std::string name) const; 00085 XMLreaderProxy operator[] (plint newId) const; 00086 bool isValid() const; 00087 plint getId() const; 00088 XMLreaderProxy iterId() const; 00089 std::string getName() const; 00090 std::vector<XMLreader*> const& getChildren() const; 00091 private: 00092 XMLreader const* reader; 00093 plint id; 00094 }; 00095 00096 class XMLwriter { 00097 public: 00098 XMLwriter(); 00099 ~XMLwriter(); 00100 template<typename T> void set(T const& value); 00101 void setString(std::string const& value); 00102 template<typename T> void set(std::vector<T> const& values); 00103 template<typename T, int N> void set(Array<T,N> const& values); 00104 XMLwriter& operator[] (std::string name); 00105 XMLwriter& operator[] (plint id); 00106 template<typename ostrT> 00107 void toOutputStream(ostrT& ostr, int indent=0) const; 00108 void print(std::string fName) const; 00109 private: 00110 XMLwriter( std::string name_ ); 00111 private: 00112 struct Data { 00113 std::string text; 00114 std::vector<XMLwriter*> children; 00115 }; 00116 private: 00117 bool isDocument; 00118 std::string name; 00119 std::map<plint,Data> data_map; 00120 plint currentId; 00121 }; 00122 00123 } // namespace plb 00124 00125 #endif // XML_IO_H
1.6.3
1.6.3