Ignore:
Timestamp:
Aug 1, 2007, 11:19:01 PM (17 years ago)
Author:
dai_9181
Message:

MetaImplを廃止し、Metaにした。
ObjectModuleクラス、Linkerクラスを用意。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abdev/BasicCompiler_Common/include/DataTable.h

    r184 r256  
    11#pragma once
     2
     3#include <BoostSerializationSupport.h>
    24
    35//DataTable.cpp
    46class DataTable{
    5     void *pdata;
     7    char *buffer;
    68    int size;
    79
     10    // XMLシリアライズ用
     11private:
     12    friend class boost::serialization::access;
     13    BOOST_SERIALIZATION_SPLIT_MEMBER();
     14    template<class Archive> void load(Archive& ar, const unsigned int version)
     15    {
     16        std::string _buffer;
     17        ar & BOOST_SERIALIZATION_NVP( _buffer );
     18        ar & BOOST_SERIALIZATION_NVP( size );
     19
     20        // 読み込み後の処理
     21        Realloc( size );
     22        for( int i=0; i<size; i++ )
     23        {
     24            if( _buffer[i*3+2] != ',' )
     25            {
     26                //エラー
     27                DebugBreak();
     28            }
     29            ULONG_PTR l;
     30            sscanf( _buffer.c_str() + i*3, "%02x,", &l );
     31            buffer[i] = (char)l;
     32        }
     33    }
     34    template<class Archive> void save(Archive& ar, const unsigned int version) const
     35    {
     36        // 保存準備
     37        char *tempCode = (char *)calloc( (size+1) * 3, 1 );
     38        for( int i=0; i<size; i++ )
     39        {
     40            char temp[32];
     41            sprintf( temp, "%02x,", (unsigned char)buffer[i] );
     42            tempCode[i*3] = temp[0];
     43            tempCode[i*3+1] = temp[1];
     44            tempCode[i*3+2] = temp[2];
     45        }
     46
     47        std::string _buffer = tempCode;
     48        free( tempCode );
     49
     50        ar & BOOST_SERIALIZATION_NVP( _buffer );
     51        ar & BOOST_SERIALIZATION_NVP( size );
     52    }
     53
    854public:
    9     DataTable();
    10     ~DataTable();
    11     void Init();
     55    DataTable()
     56        : buffer( (char *)malloc(100) )
     57        , size( 0 )
     58    {
     59        lstrcpy( buffer, "initialized!!!" );
     60    }
     61    DataTable( const DataTable &dataTable )
     62        : buffer( (char *)malloc(100) )
     63        , size( 0 )
     64    {
     65        lstrcpy( buffer, "initialized!!!" );
     66        AddBinary( dataTable.GetPtr(), dataTable.GetSize() );
     67    }
     68    ~DataTable()
     69    {
     70        free( buffer );
     71    }
     72    void Clear()
     73    {
     74        size = 0;
     75    }
    1276
    13     int AddBinary( const void *pdata, int size );
     77    void operator =( const DataTable &dataTable )
     78    {
     79        Clear();
     80        AddBinary( dataTable.GetPtr(), dataTable.GetSize() );
     81    }
     82
     83    void Realloc( int size );
     84    int AddBinary( const void *buffer, int size );
    1485    int Add( _int64 i64data );
    1586    int Add( int i32data );
Note: See TracChangeset for help on using the changeset viewer.