Changeset 205 in dev for trunk/jenga/include/common/BoostXmlSupport.h
- Timestamp:
- Jul 12, 2007, 2:57:04 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/jenga/include/common/BoostXmlSupport.h
r190 r205 19 19 #include <boost/serialization/is_abstract.hpp> 20 20 21 #include <windows.h> 22 21 23 namespace Jenga{ 22 24 namespace Common{ … … 27 29 virtual const char *RootTagName() const = 0; 28 30 31 void echo( const char *msg ) const 32 { 33 MessageBox( NULL, msg, "XMLシリアライズの例外", MB_OK ); 34 } 35 29 36 public: 30 bool Read( istream& ifs )37 bool Read( istream& ifs, bool isShowExceptionMessage = true ) 31 38 { 32 39 bool isSuccessful = false; … … 40 47 isSuccessful = true; 41 48 } 49 catch( boost::archive::archive_exception e ) 50 { 51 if( isShowExceptionMessage ) 52 { 53 echo( e.what() ); 54 } 55 } 42 56 catch(...){ 43 // 失敗 57 if( isShowExceptionMessage ) 58 { 59 echo( "archive_exception以外の不明な例外" ); 60 } 44 61 } 45 62 … … 52 69 } 53 70 54 bool Write( ostream& ofs ) const71 bool Write( ostream& ofs, bool isShowExceptionMessage = true ) const 55 72 { 56 73 bool isSuccessful = false; … … 64 81 isSuccessful = true; 65 82 } 66 catch( ... ){ 67 // 失敗 83 catch( boost::archive::archive_exception e ) 84 { 85 if( isShowExceptionMessage ) 86 { 87 echo( e.what() ); 88 } 89 } 90 catch(...){ 91 if( isShowExceptionMessage ) 92 { 93 echo( "archive_exception以外の不明な例外" ); 94 } 68 95 } 69 96 … … 76 103 } 77 104 78 bool Read( const string &xmlFilePath )105 bool Read( const string &xmlFilePath, bool isShowExceptionMessage = true ) 79 106 { 80 107 bool isSuccessful = false; … … 83 110 std::ifstream ifs( xmlFilePath.c_str() ); 84 111 85 bool result = Read(ifs );112 bool result = Read(ifs,isShowExceptionMessage); 86 113 87 114 // 入力を閉じる … … 91 118 } 92 119 93 bool Write( const string &xmlFilePath ) const120 bool Write( const string &xmlFilePath, bool isShowExceptionMessage = true ) const 94 121 { 95 122 // 出力アーカイブの作成 96 123 std::ofstream ofs( xmlFilePath.c_str() ); 97 124 98 bool result = Write(ofs );125 bool result = Write(ofs,isShowExceptionMessage); 99 126 100 127 // 出力を閉じる … … 104 131 } 105 132 106 bool ReadFromString( const wstring &xmlBuffer )133 bool ReadFromString( const string &xmlBuffer ) 107 134 { 108 135 bool isSuccessful = false;
Note:
See TracChangeset
for help on using the changeset viewer.