[206] | 1 | #include "stdafx.h"
|
---|
| 2 |
|
---|
[256] | 3 | int DataTable::AddBinary( const void *buffer, int size ){
|
---|
[184] | 4 | int retSize = this->size;
|
---|
| 5 |
|
---|
[256] | 6 | Realloc( this->size + size );
|
---|
| 7 | memcpy( (char *)this->buffer + retSize, buffer, size );
|
---|
[184] | 8 |
|
---|
| 9 | return retSize;
|
---|
| 10 | }
|
---|
| 11 | int DataTable::Add( _int64 i64data ){
|
---|
| 12 | int retSize = size;
|
---|
| 13 | AddBinary( &i64data, sizeof( _int64 ) );
|
---|
| 14 | return retSize;
|
---|
| 15 | }
|
---|
| 16 | int DataTable::Add( int i32data ){
|
---|
| 17 | int retSize = size;
|
---|
| 18 | AddBinary( &i32data, sizeof( int ) );
|
---|
| 19 | return retSize;
|
---|
| 20 | }
|
---|
| 21 | int DataTable::Add( double dbl ){
|
---|
| 22 | int retSize = size;
|
---|
| 23 | AddBinary( &dbl, sizeof( double ) );
|
---|
| 24 | return retSize;
|
---|
| 25 | }
|
---|
| 26 | int DataTable::Add( float flt ){
|
---|
| 27 | int retSize = size;
|
---|
| 28 | AddBinary( &flt, sizeof( float ) );
|
---|
| 29 | return retSize;
|
---|
| 30 | }
|
---|
[387] | 31 | int DataTable::AddString( const char *str )
|
---|
| 32 | {
|
---|
[591] | 33 | return AddBinary( str, lstrlen( str ) + sizeof(char) );
|
---|
[387] | 34 | }
|
---|
| 35 | int DataTable::AddString( const std::string &str )
|
---|
| 36 | {
|
---|
[591] | 37 | return AddBinary( str.c_str(), static_cast<int>(str.size()) + sizeof(char) );
|
---|
[387] | 38 | }
|
---|
[591] | 39 | int DataTable::AddWString( const std::wstring &wstr )
|
---|
| 40 | {
|
---|
| 41 | return AddBinary( wstr.c_str(), static_cast<int>(wstr.size()) + sizeof(wchar_t) );
|
---|
| 42 | }
|
---|
[387] | 43 | int DataTable::AddSpace( int size )
|
---|
| 44 | {
|
---|
| 45 | int retSize = this->size;
|
---|
| 46 | Realloc( this->size + size );
|
---|
[184] | 47 | return retSize;
|
---|
| 48 | }
|
---|
[387] | 49 | void DataTable::AddAlignment( int size )
|
---|
| 50 | {
|
---|
| 51 | if( this->size % size == 0 )
|
---|
| 52 | {
|
---|
| 53 | // 既に境界のとき
|
---|
| 54 | return;
|
---|
| 55 | }
|
---|
| 56 | Realloc( this->size + ( size - (int)(this->size%size) ) );
|
---|
| 57 | }
|
---|
[184] | 58 |
|
---|
[355] | 59 | void DataTable::ResetDataSectionBaseOffset( long dataSectionBaseOffset )
|
---|
| 60 | {
|
---|
| 61 | BOOST_FOREACH( const Schedule &schedule, schedules )
|
---|
| 62 | {
|
---|
| 63 | if( schedule.GetType() == Schedule::DataTable )
|
---|
| 64 | {
|
---|
| 65 | #ifdef _WIN64
|
---|
| 66 | OverwriteInt64(
|
---|
| 67 | schedule.GetOffset(),
|
---|
| 68 | GetInt64( schedule.GetOffset() ) + dataSectionBaseOffset
|
---|
| 69 | );
|
---|
| 70 | #else
|
---|
| 71 | Overwrite(
|
---|
| 72 | schedule.GetOffset(),
|
---|
| 73 | GetLong( schedule.GetOffset() ) + dataSectionBaseOffset
|
---|
| 74 | );
|
---|
| 75 | #endif
|
---|
| 76 | }
|
---|
| 77 | }
|
---|
| 78 | }
|
---|