Changeset 213 in dev


Ignore:
Timestamp:
Jul 16, 2007, 11:35:45 PM (17 years ago)
Author:
dai_9181
Message:

BoostXmlSupportクラスの名前をBoostSerializationSupportに変更

Location:
trunk/jenga
Files:
4 edited
1 moved

Legend:

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

    r209 r213  
    88#include <boost/archive/xml_oarchive.hpp>
    99#include <boost/archive/xml_iarchive.hpp>
     10#include <boost/archive/binary_oarchive.hpp>
     11#include <boost/archive/binary_iarchive.hpp>
    1012#include <boost/serialization/serialization.hpp>
    1113#include <boost/serialization/string.hpp>
     
    2628using namespace std;
    2729
    28 template<class T_xml_schema> class BoostXmlSupport{
     30template<class T_xml_schema> class BoostSerializationSupport{
    2931    virtual const char *RootTagName() const = 0;
    3032
     
    3537
    3638public:
    37     bool Read( istream& ifs, bool isShowExceptionMessage = true )
     39    bool ReadXml( istream& ifs, bool isShowExceptionMessage = true )
    3840    {
    3941        bool isSuccessful = false;
     
    6971    }
    7072
    71     bool Write( ostream& ofs, bool isShowExceptionMessage = true ) const
     73    bool WriteXml( ostream& ofs, bool isShowExceptionMessage = true ) const
    7274    {
    7375        bool isSuccessful = false;
     
    103105    }
    104106
    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    {
    109109        // 入力アーカイブの作成
    110110        std::ifstream ifs( xmlFilePath.c_str() );
    111111       
    112         bool result = Read(ifs,isShowExceptionMessage);
     112        bool result = ReadXml(ifs,isShowExceptionMessage);
    113113
    114114        // 入力を閉じる
     
    117117        return result;
    118118    }
    119 
    120     bool Write( const string &xmlFilePath, bool isShowExceptionMessage = true ) const
     119    bool WriteXml( const string &xmlFilePath, bool isShowExceptionMessage = true ) const
    121120    {
    122121        // 出力アーカイブの作成
    123122        std::ofstream ofs( xmlFilePath.c_str() );
    124123
    125         bool result = Write(ofs,isShowExceptionMessage);
     124        bool result = WriteXml(ofs,isShowExceptionMessage);
    126125
    127126        // 出力を閉じる
     
    131130    }
    132131
    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 )
    134210    {
    135211        bool isSuccessful = false;
     
    157233        return true;
    158234    }
    159     bool ToWString( wstring &xmlBuffer ) const
     235    bool ToXmlWString( wstring &xmlBuffer ) const
    160236    {
    161237        bool isSuccessful = false;
  • trunk/jenga/include/common/Hashmap.h

    r207 r213  
    88#include <jenga/include/common/Exception.h>
    99
    10 #include "BoostXmlSupport.h"
     10#include "BoostSerializationSupport.h"
    1111
    1212
  • trunk/jenga/include/common/logger.h

    r205 r213  
    1313
    1414#include <jenga/include/common/Environment.h>
    15 #include <jenga/include/common/BoostXmlSupport.h>
     15#include <jenga/include/common/BoostSerializationSupport.h>
    1616
    1717#define STDX_DSTREAM_BUFFERING
     
    2424
    2525
    26 class LoggerSetting : public BoostXmlSupport<LoggerSetting>
     26class LoggerSetting : public BoostSerializationSupport<LoggerSetting>
    2727{
    2828public:
     
    7373            char temp3[MAX_PATH];
    7474            _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 );
    7676        }
    7777    }
  • trunk/jenga/include/smoothie/Namespace.h

    r200 r213  
    55#include <boost/foreach.hpp>
    66
    7 #include <jenga/include/common/BoostXmlSupport.h>
     7#include <jenga/include/common/BoostSerializationSupport.h>
    88
    99using namespace std;
  • trunk/jenga/projects/common/common.vcproj

    r205 r213  
    296296            >
    297297            <File
    298                 RelativePath="..\..\include\common\BoostXmlSupport.h"
     298                RelativePath="..\..\include\common\BoostSerializationSupport.h"
    299299                >
    300300            </File>
Note: See TracChangeset for help on using the changeset viewer.