Changeset 213 in dev
- Timestamp:
- Jul 16, 2007, 11:35:45 PM (17 years ago)
- Location:
- trunk/jenga
- Files:
-
- 4 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/jenga/include/common/BoostSerializationSupport.h
r209 r213 8 8 #include <boost/archive/xml_oarchive.hpp> 9 9 #include <boost/archive/xml_iarchive.hpp> 10 #include <boost/archive/binary_oarchive.hpp> 11 #include <boost/archive/binary_iarchive.hpp> 10 12 #include <boost/serialization/serialization.hpp> 11 13 #include <boost/serialization/string.hpp> … … 26 28 using namespace std; 27 29 28 template<class T_xml_schema> class Boost XmlSupport{30 template<class T_xml_schema> class BoostSerializationSupport{ 29 31 virtual const char *RootTagName() const = 0; 30 32 … … 35 37 36 38 public: 37 bool Read ( istream& ifs, bool isShowExceptionMessage = true )39 bool ReadXml( istream& ifs, bool isShowExceptionMessage = true ) 38 40 { 39 41 bool isSuccessful = false; … … 69 71 } 70 72 71 bool Write ( ostream& ofs, bool isShowExceptionMessage = true ) const73 bool WriteXml( ostream& ofs, bool isShowExceptionMessage = true ) const 72 74 { 73 75 bool isSuccessful = false; … … 103 105 } 104 106 105 bool Read( const string &xmlFilePath, bool isShowExceptionMessage = true ) 106 { 107 bool isSuccessful = false; 108 107 bool ReadXml( const string &xmlFilePath, bool isShowExceptionMessage = true ) 108 { 109 109 // 入力アーカイブの作成 110 110 std::ifstream ifs( xmlFilePath.c_str() ); 111 111 112 bool result = Read (ifs,isShowExceptionMessage);112 bool result = ReadXml(ifs,isShowExceptionMessage); 113 113 114 114 // 入力を閉じる … … 117 117 return result; 118 118 } 119 120 bool Write( const string &xmlFilePath, bool isShowExceptionMessage = true ) const 119 bool WriteXml( const string &xmlFilePath, bool isShowExceptionMessage = true ) const 121 120 { 122 121 // 出力アーカイブの作成 123 122 std::ofstream ofs( xmlFilePath.c_str() ); 124 123 125 bool result = Write (ofs,isShowExceptionMessage);124 bool result = WriteXml(ofs,isShowExceptionMessage); 126 125 127 126 // 出力を閉じる … … 131 130 } 132 131 133 bool ReadFromString( const string &xmlBuffer ) 132 bool ReadBinaly( const string &xmlFilePath, bool isShowExceptionMessage = true ) 133 { 134 // 入力アーカイブの作成 135 std::ifstream ifs( xmlFilePath.c_str() ); 136 137 bool isSuccessful = false; 138 try{ 139 boost::archive::binary_iarchive ia(ifs); 140 141 // ファイルから読込 142 ia >> boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this ); 143 144 isSuccessful = true; 145 } 146 catch( boost::archive::archive_exception e ) 147 { 148 if( isShowExceptionMessage ) 149 { 150 echo( e.what() ); 151 } 152 } 153 catch(...){ 154 if( isShowExceptionMessage ) 155 { 156 echo( "archive_exception以外の不明な例外" ); 157 } 158 } 159 160 // 入力を閉じる 161 ifs.close(); 162 163 if( !isSuccessful ) 164 { 165 return false; 166 } 167 168 return true; 169 } 170 bool WriteBinaly( const string &xmlFilePath, bool isShowExceptionMessage = true ) const 171 { 172 // 出力アーカイブの作成 173 std::ofstream ofs( xmlFilePath.c_str() ); 174 175 bool isSuccessful = false; 176 try{ 177 boost::archive::binary_oarchive oa(ofs); 178 179 // ファイルに書き出し 180 oa << boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this ); 181 182 isSuccessful = true; 183 } 184 catch( boost::archive::archive_exception e ) 185 { 186 if( isShowExceptionMessage ) 187 { 188 echo( e.what() ); 189 } 190 } 191 catch(...){ 192 if( isShowExceptionMessage ) 193 { 194 echo( "archive_exception以外の不明な例外" ); 195 } 196 } 197 198 // 出力を閉じる 199 ofs.close(); 200 201 if( !isSuccessful ) 202 { 203 return false; 204 } 205 206 return true; 207 } 208 209 bool ReadXmlFromString( const string &xmlBuffer ) 134 210 { 135 211 bool isSuccessful = false; … … 157 233 return true; 158 234 } 159 bool To WString( wstring &xmlBuffer ) const235 bool ToXmlWString( wstring &xmlBuffer ) const 160 236 { 161 237 bool isSuccessful = false; -
trunk/jenga/include/common/Hashmap.h
r207 r213 8 8 #include <jenga/include/common/Exception.h> 9 9 10 #include "Boost XmlSupport.h"10 #include "BoostSerializationSupport.h" 11 11 12 12 -
trunk/jenga/include/common/logger.h
r205 r213 13 13 14 14 #include <jenga/include/common/Environment.h> 15 #include <jenga/include/common/Boost XmlSupport.h>15 #include <jenga/include/common/BoostSerializationSupport.h> 16 16 17 17 #define STDX_DSTREAM_BUFFERING … … 24 24 25 25 26 class LoggerSetting : public Boost XmlSupport<LoggerSetting>26 class LoggerSetting : public BoostSerializationSupport<LoggerSetting> 27 27 { 28 28 public: … … 73 73 char temp3[MAX_PATH]; 74 74 _splitpath(saveFilePath.c_str(),temporary,temp2,temp3,NULL); 75 setting.Read ( (string)temporary + temp2 + temp3 + ".setting.xml", false );75 setting.ReadXml( (string)temporary + temp2 + temp3 + ".setting.xml", false ); 76 76 } 77 77 } -
trunk/jenga/include/smoothie/Namespace.h
r200 r213 5 5 #include <boost/foreach.hpp> 6 6 7 #include <jenga/include/common/Boost XmlSupport.h>7 #include <jenga/include/common/BoostSerializationSupport.h> 8 8 9 9 using namespace std; -
trunk/jenga/projects/common/common.vcproj
r205 r213 296 296 > 297 297 <File 298 RelativePath="..\..\include\common\Boost XmlSupport.h"298 RelativePath="..\..\include\common\BoostSerializationSupport.h" 299 299 > 300 300 </File>
Note:
See TracChangeset
for help on using the changeset viewer.