Changeset 404 in dev
- Timestamp:
- Mar 1, 2008, 12:00:47 AM (17 years ago)
- Location:
- trunk/abdev
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler32/BasicCompiler.vcproj
r400 r404 1348 1348 RelativePath="..\BasicCompiler_Common\src\ObjectModule.cpp" 1349 1349 > 1350 <FileConfiguration 1351 Name="Release|Win32" 1352 > 1353 <Tool 1354 Name="VCCLCompilerTool" 1355 UsePrecompiledHeader="0" 1356 /> 1357 </FileConfiguration> 1350 1358 </File> 1351 1359 <File -
trunk/abdev/BasicCompiler64/BasicCompiler.vcproj
r400 r404 1311 1311 RelativePath="..\BasicCompiler_Common\src\ObjectModule.cpp" 1312 1312 > 1313 <FileConfiguration 1314 Name="Release|Win32" 1315 > 1316 <Tool 1317 Name="VCCLCompilerTool" 1318 UsePrecompiledHeader="0" 1319 /> 1320 </FileConfiguration> 1313 1321 </File> 1314 1322 <File -
trunk/abdev/BasicCompiler_Common/include/BoostSerializationSupport.h
r322 r404 33 33 bool WriteBinaryString( std::string &binaryString ) const; 34 34 35 /* 36 ビルドに時間がかかるので外しておく 35 37 bool ReadText( const std::string &filePath, bool isShowExceptionMessage = true ); 36 38 bool WriteText( const std::string &filePath, bool isShowExceptionMessage = true ) const; … … 39 41 40 42 bool ReadXmlFromString( const std::string &xmlBuffer ); 43 */ 41 44 }; 42 45 -
trunk/abdev/BasicCompiler_Common/include/ObjectModule.h
r280 r404 1 1 #pragma once 2 2 3 class ObjectModule : public Jenga::Common::BoostSerializationSupport<ObjectModule>3 class ObjectModule 4 4 { 5 5 public: -
trunk/abdev/BasicCompiler_Common/src/BoostSerializationSupport.cpp
r353 r404 34 34 35 35 #include <BoostSerializationSupport.h> 36 #include <Hashmap.h>37 #include <Compiler.h>38 36 39 37 using namespace Jenga::Common; … … 320 318 } 321 319 320 /* 321 ビルドに時間がかかるので外しておく 322 322 template<class T_xml_schema> bool BoostSerializationSupport<T_xml_schema>::ReadText( const string &filePath, bool isShowExceptionMessage ) 323 323 { … … 481 481 return true; 482 482 } 483 484 485 #include <Compiler.h> 483 */ 484 485 486 486 #include <logger.h> 487 487 488 template class Jenga::Common::BoostSerializationSupport<ObjectModule>;489 488 template class Jenga::Common::BoostSerializationSupport<LoggerSetting>; -
trunk/abdev/BasicCompiler_Common/src/ObjectModule.cpp
r395 r404 1 #include "stdafx.h" 2 1 #include <string> 2 #include <vector> 3 #include <fstream> 4 5 #include <windows.h> 6 #include <stdio.h> 7 #include <string.h> 8 #include <math.h> 9 #include <commctrl.h> 10 #include <time.h> 11 #include <limits.h> 12 #include <shlobj.h> 13 14 //boost libraries 15 #include <boost/foreach.hpp> 16 17 #include <jenga/include/common/String.h> 18 19 #include "../common.h" 20 21 22 // ObjectModuleの内容をXmlで生成する場合はこの行を有効にする 23 //#define OBJECT_MODULE_IS_NOT_BINARY 24 25 26 #ifdef OBJECT_MODULE_IS_NOT_BINARY 27 #include <boost/archive/xml_oarchive.hpp> 28 #include <boost/archive/xml_iarchive.hpp> 29 #else 30 #include <boost/archive/binary_oarchive.hpp> 31 #include <boost/archive/binary_iarchive.hpp> 32 #endif 33 #include <boost/serialization/string.hpp> 34 #include <boost/serialization/access.hpp> 35 #include <boost/serialization/level.hpp> 36 #include <boost/serialization/vector.hpp> 37 #include <boost/serialization/map.hpp> 38 #include <boost/serialization/version.hpp> 39 #include <boost/serialization/is_abstract.hpp> 40 41 #include <BoostSerializationSupport.h> 42 #include <Hashmap.h> 3 43 #include <Compiler.h> 4 5 enum ObjectModuleDataType6 {7 ObjectModuleDataTypeXml,8 ObjectModuleDataTypeText,9 ObjectModuleDataTypeBinaly,10 };11 const ObjectModuleDataType objectModuleDataType = ObjectModuleDataTypeBinaly;12 44 13 45 … … 42 74 bool ObjectModule::Read( const std::string &filePath ) 43 75 { 44 switch( objectModuleDataType ) 45 { 46 case ObjectModuleDataTypeXml: 47 return ReadXml( filePath ); 48 case ObjectModuleDataTypeText: 49 return ReadText( filePath ); 50 case ObjectModuleDataTypeBinaly: 51 return ReadBinaryFile( filePath ); 52 default: 53 Jenga::Throw( "" ); 54 break; 55 } 56 return false; 76 // XMLとして読み込む 77 bool isSuccessful = false; 78 79 try{ 80 #ifdef OBJECT_MODULE_IS_NOT_BINARY 81 std::ifstream ifs( filePath.c_str() ); 82 boost::archive::xml_iarchive ia(ifs); 83 #else 84 std::ifstream ifs( filePath.c_str(), ios::in | ios::binary ); 85 boost::archive::binary_iarchive ia(ifs); 86 #endif 87 88 // ファイルから読込 89 ia >> boost::serialization::make_nvp( RootTagName(), *this ); 90 91 isSuccessful = true; 92 } 93 catch( boost::archive::archive_exception e ) 94 { 95 MessageBox( NULL, e.what(), "XMLシリアライズの例外", MB_OK ); 96 } 97 catch(...){ 98 MessageBox( NULL, "archive_exception以外の不明な例外", "XMLシリアライズの例外", MB_OK ); 99 } 100 101 if( !isSuccessful ) 102 { 103 return false; 104 } 105 106 return true; 57 107 } 58 108 bool ObjectModule::Write( const std::string &filePath ) const 59 109 { 60 switch( objectModuleDataType ) 61 { 62 case ObjectModuleDataTypeXml: 63 return WriteXml( filePath ); 64 case ObjectModuleDataTypeText: 65 return WriteText( filePath ); 66 case ObjectModuleDataTypeBinaly: 67 return WriteBinaryFile( filePath ); 68 default: 69 Jenga::Throw( "" ); 70 break; 71 } 72 return false; 110 bool isSuccessful = false; 111 112 try{ 113 #ifdef OBJECT_MODULE_IS_NOT_BINARY 114 std::ofstream ofs( filePath.c_str() ); 115 boost::archive::xml_oarchive oa(ofs); 116 #else 117 std::ofstream ofs( filePath.c_str(), ios::out | ios::binary ); 118 boost::archive::binary_oarchive oa(ofs); 119 #endif 120 121 // ファイルに書き出し 122 oa << boost::serialization::make_nvp( RootTagName(), *this ); 123 124 isSuccessful = true; 125 } 126 catch( boost::archive::archive_exception e ) 127 { 128 MessageBox( NULL, e.what(), "XMLシリアライズの例外", MB_OK ); 129 } 130 catch(...){ 131 MessageBox( NULL, "archive_exception以外の不明な例外", "XMLシリアライズの例外", MB_OK ); 132 } 133 134 if( !isSuccessful ) 135 { 136 return false; 137 } 138 139 return true; 73 140 } 74 141 bool ObjectModule::ReadString( const std::string &str ) 75 142 { 76 switch( objectModuleDataType ) 77 { 78 case ObjectModuleDataTypeXml: 79 return ReadXmlString( str ); 80 case ObjectModuleDataTypeText: 81 return ReadTextString( str ); 82 case ObjectModuleDataTypeBinaly: 83 return ReadBinaryString( str ); 84 default: 85 Jenga::Throw( "" ); 86 break; 87 } 88 return false; 143 bool isSuccessful = false; 144 145 // 入力アーカイブの作成 146 147 try{ 148 #ifdef OBJECT_MODULE_IS_NOT_BINARY 149 std::istringstream iss( str ); 150 boost::archive::xml_iarchive ia(iss); 151 #else 152 std::istringstream iss( str, ios::in | ios::binary ); 153 boost::archive::binary_iarchive ia(iss); 154 #endif 155 156 // 文字列ストリームから読込 157 ia >> boost::serialization::make_nvp( RootTagName(), *this ); 158 159 isSuccessful = true; 160 } 161 catch( boost::archive::archive_exception e ) 162 { 163 MessageBox( NULL, e.what(), "XMLシリアライズの例外", MB_OK ); 164 } 165 catch(...){ 166 MessageBox( NULL, "archive_exception以外の不明な例外", "XMLシリアライズの例外", MB_OK ); 167 } 168 169 if( !isSuccessful ) 170 { 171 return false; 172 } 173 174 return true; 89 175 } 90 176 bool ObjectModule::WriteString( std::string &str ) const 91 177 { 92 switch( objectModuleDataType ) 93 { 94 case ObjectModuleDataTypeXml: 95 return WriteXmlString( str ); 96 case ObjectModuleDataTypeText: 97 return WriteTextString( str ); 98 case ObjectModuleDataTypeBinaly: 99 return WriteBinaryString( str ); 100 default: 101 Jenga::Throw( "" ); 102 break; 103 } 104 return false; 105 } 178 // 出力アーカイブの作成 179 180 bool isSuccessful = false; 181 try{ 182 #ifdef OBJECT_MODULE_IS_NOT_BINARY 183 std::ostringstream oss; 184 boost::archive::xml_oarchive oa(oss); 185 #else 186 std::ostringstream oss( "", ios::out | ios::binary ); 187 boost::archive::binary_oarchive oa(oss); 188 #endif 189 190 // 文字列ストリームに書き出し 191 oa << boost::serialization::make_nvp( RootTagName(), *this ); 192 193 str = oss.str(); 194 195 isSuccessful = true; 196 } 197 catch( boost::archive::archive_exception e ) 198 { 199 MessageBox( NULL, e.what(), "XMLシリアライズの例外", MB_OK ); 200 } 201 catch(...){ 202 MessageBox( NULL, "archive_exception以外の不明な例外", "XMLシリアライズの例外", MB_OK ); 203 } 204 205 return isSuccessful; 206 }
Note:
See TracChangeset
for help on using the changeset viewer.