Ignore:
Timestamp:
Jul 12, 2007, 2:57:04 AM (17 years ago)
Author:
dai_9181
Message:

コード全体のリファクタリングを実施

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/jenga/include/common/BoostXmlSupport.h

    r190 r205  
    1919#include <boost/serialization/is_abstract.hpp>
    2020
     21#include <windows.h>
     22
    2123namespace Jenga{
    2224namespace Common{
     
    2729    virtual const char *RootTagName() const = 0;
    2830
     31    void echo( const char *msg ) const
     32    {
     33        MessageBox( NULL, msg, "XMLシリアライズの例外", MB_OK );
     34    }
     35
    2936public:
    30     bool Read( istream& ifs )
     37    bool Read( istream& ifs, bool isShowExceptionMessage = true )
    3138    {
    3239        bool isSuccessful = false;
     
    4047            isSuccessful = true;
    4148        }
     49        catch( boost::archive::archive_exception e )
     50        {
     51            if( isShowExceptionMessage )
     52            {
     53                echo( e.what() );
     54            }
     55        }
    4256        catch(...){
    43             // 失敗
     57            if( isShowExceptionMessage )
     58            {
     59                echo( "archive_exception以外の不明な例外" );
     60            }
    4461        }
    4562
     
    5269    }
    5370
    54     bool Write( ostream& ofs ) const
     71    bool Write( ostream& ofs, bool isShowExceptionMessage = true ) const
    5572    {
    5673        bool isSuccessful = false;
     
    6481            isSuccessful = true;
    6582        }
    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            }
    6895        }
    6996
     
    76103    }
    77104
    78     bool Read( const string &xmlFilePath )
     105    bool Read( const string &xmlFilePath, bool isShowExceptionMessage = true )
    79106    {
    80107        bool isSuccessful = false;
     
    83110        std::ifstream ifs( xmlFilePath.c_str() );
    84111       
    85         bool result = Read(ifs);
     112        bool result = Read(ifs,isShowExceptionMessage);
    86113
    87114        // 入力を閉じる
     
    91118    }
    92119
    93     bool Write( const string &xmlFilePath ) const
     120    bool Write( const string &xmlFilePath, bool isShowExceptionMessage = true ) const
    94121    {
    95122        // 出力アーカイブの作成
    96123        std::ofstream ofs( xmlFilePath.c_str() );
    97124
    98         bool result = Write(ofs);
     125        bool result = Write(ofs,isShowExceptionMessage);
    99126
    100127        // 出力を閉じる
     
    104131    }
    105132
    106     bool ReadFromString( const wstring &xmlBuffer )
     133    bool ReadFromString( const string &xmlBuffer )
    107134    {
    108135        bool isSuccessful = false;
Note: See TracChangeset for help on using the changeset viewer.