Changeset 815 in dev


Ignore:
Timestamp:
Mar 19, 2011, 2:01:10 AM (13 years ago)
Author:
イグトランス (egtra)
Message:

BoostSerializationSupport.cppで、boost::polymorphic_downcastを使うよう変更。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/egtra/ab5.0/abdev/BasicCompiler_Common/src/BoostSerializationSupport.cpp

    r806 r815  
    1717#include <limits.h>
    1818#include <shlobj.h>
    19 #include <process.h>
    20 #include <fcntl.h>
    21 #include <io.h>
    2219#include <shlwapi.h>
    2320#include <tchar.h>
    24 #include <stdarg.h>
    2521
    2622//boost libraries
    2723#include <boost/foreach.hpp>
    28 
     24#include <boost/cast.hpp>
     25
     26#pragma warning(push)
     27#pragma warning(disable: 4244 6326)
    2928#include <boost/archive/xml_oarchive.hpp>
    3029#include <boost/archive/xml_iarchive.hpp>
     
    3938#include <boost/serialization/map.hpp>
    4039#include <boost/serialization/version.hpp>
     40#pragma warning(pop)
    4141
    4242#include <jenga/include/jenga.h>
     
    4646using namespace Jenga::Common;
    4747
     48using boost::polymorphic_downcast;
     49
    4850template<class T_xml_schema> void BoostSerializationSupport<T_xml_schema>::echo( const char *msg ) const
    4951{
    50     MessageBox( NULL, msg, "XMLシリアライズの例外", MB_OK );
     52    MessageBox( NULL, msg, "シリアライズの例外", MB_OK );
    5153}
    5254template<class T_xml_schema> bool BoostSerializationSupport<T_xml_schema>::ReadXml( std::istream& ifs, bool isShowExceptionMessage )
     
    5860
    5961        // ファイルから読込
    60         ia >> boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
    61 
    62         isSuccessful = true;
    63     }
    64     catch( boost::archive::archive_exception e )
     62        ia >> boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema*>(this) );
     63
     64        isSuccessful = true;
     65    }
     66    catch( boost::archive::archive_exception const& e )
    6567    {
    6668        if( isShowExceptionMessage )
     
    9193
    9294        // ファイルに書き出し
    93         oa << boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
    94 
    95         isSuccessful = true;
    96     }
    97     catch( boost::archive::archive_exception e )
     95        oa << boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema const*>(this) );
     96
     97        isSuccessful = true;
     98    }
     99    catch( boost::archive::archive_exception const& e )
    98100    {
    99101        if( isShowExceptionMessage )
     
    151153
    152154        // 文字列ストリームから読込
    153         ia >> boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
     155        ia >> boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema*>(this) );
    154156
    155157        isSuccessful = true;
     
    176178
    177179        // 文字列ストリームに書き出し
    178         oa << boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
    179 
    180         isSuccessful = true;
    181     }
    182     catch( boost::archive::archive_exception e )
     180        oa << boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema const*>(this) );
     181
     182        isSuccessful = true;
     183    }
     184    catch( boost::archive::archive_exception const& e )
    183185    {
    184186        echo( e.what() );
     
    208210
    209211        // ファイルから読込
    210         ia >> boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
    211 
    212         isSuccessful = true;
    213     }
    214     catch( boost::archive::archive_exception e )
     212        ia >> boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema*>(this) );
     213
     214        isSuccessful = true;
     215    }
     216    catch( boost::archive::archive_exception const& e )
    215217    {
    216218        if( isShowExceptionMessage )
     
    246248
    247249        // ファイルに書き出し
    248         oa << boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
    249 
    250         isSuccessful = true;
    251     }
    252     catch( boost::archive::archive_exception e )
     250        oa << boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema const*>(this) );
     251
     252        isSuccessful = true;
     253    }
     254    catch( boost::archive::archive_exception const& e )
    253255    {
    254256        if( isShowExceptionMessage )
     
    286288
    287289        // 文字列ストリームから読込
    288         ia >> boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
    289 
    290         isSuccessful = true;
    291     }
    292     catch( boost::archive::archive_exception e )
     290        ia >> boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema*>(this) );
     291
     292        isSuccessful = true;
     293    }
     294    catch( boost::archive::archive_exception const& e )
    293295    {
    294296        echo( e.what() );
     
    310312
    311313        // 文字列ストリームに書き出し
    312         oa << boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
    313 
    314         isSuccessful = true;
    315     }
    316     catch( boost::archive::archive_exception e )
     314        oa << boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema const*>(this) );
     315
     316        isSuccessful = true;
     317    }
     318    catch( boost::archive::archive_exception const& e )
    317319    {
    318320        echo( e.what() );
     
    339341
    340342        // ファイルから読込
    341         ia >> boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
    342 
    343         isSuccessful = true;
    344     }
    345     catch( boost::archive::archive_exception e )
     343        ia >> boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema*>(this) );
     344
     345        isSuccessful = true;
     346    }
     347    catch( boost::archive::archive_exception const& e )
    346348    {
    347349        if( isShowExceptionMessage )
     
    377379
    378380        // ファイルに書き出し
    379         oa << boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
    380 
    381         isSuccessful = true;
    382     }
    383     catch( boost::archive::archive_exception e )
     381        oa << boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema const*>(this) );
     382
     383        isSuccessful = true;
     384    }
     385    catch( boost::archive::archive_exception const& e )
    384386    {
    385387        if( isShowExceptionMessage )
     
    417419
    418420        // 文字列ストリームから読込
    419         ia >> boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
     421        ia >> boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema*>(this) );
    420422
    421423        isSuccessful = true;
     
    442444
    443445        // 文字列ストリームに書き出し
    444         oa << boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
    445 
    446         isSuccessful = true;
    447     }
    448     catch( boost::archive::archive_exception e )
     446        oa << boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema const*>(this) );
     447
     448        isSuccessful = true;
     449    }
     450    catch( boost::archive::archive_exception const& e )
    449451    {
    450452        echo( e.what() );
     
    475477
    476478        // 文字列ストリームから読込
    477         ia >> boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
     479        ia >> boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema*>(this) );
    478480
    479481        isSuccessful = true;
Note: See TracChangeset for help on using the changeset viewer.