source: dev/trunk/ab5.0/abdev/ab_common/src/Lexical/DataTable.cpp@ 779

Last change on this file since 779 was 750, checked in by イグトランス (egtra), 16 years ago

BOOST_FOREACHを可能なものはVC++ 2005 for eachへ置換(やや速くなる)。

File size: 2.0 KB
Line 
1#include "stdafx.h"
2
3int DataTable::AddBinary( const void *buffer, int size ){
4 int retSize = this->size;
5
6 Realloc( this->size + size );
7 memcpy( (char *)this->buffer + retSize, buffer, size );
8
9 return retSize;
10}
11int DataTable::Add( _int64 i64data ){
12 int retSize = size;
13 AddBinary( &i64data, sizeof( _int64 ) );
14 return retSize;
15}
16int DataTable::Add( int i32data ){
17 int retSize = size;
18 AddBinary( &i32data, sizeof( int ) );
19 return retSize;
20}
21int DataTable::Add( double dbl ){
22 int retSize = size;
23 AddBinary( &dbl, sizeof( double ) );
24 return retSize;
25}
26int DataTable::Add( float flt ){
27 int retSize = size;
28 AddBinary( &flt, sizeof( float ) );
29 return retSize;
30}
31int DataTable::AddString( const char *str )
32{
33 return AddBinary( str, strlen( str ) + sizeof(char) );
34}
35int DataTable::AddString( const std::string &str )
36{
37 return AddBinary( str.c_str(), static_cast<int>(str.size()) + sizeof(char) );
38}
39int DataTable::AddWString( const std::wstring &wstr )
40{
41 return AddBinary( wstr.c_str(), static_cast<int>((wstr.length()+1)*sizeof(wchar_t)));
42}
43int DataTable::AddSpace( int size )
44{
45 int retSize = this->size;
46 Realloc( this->size + size );
47 return retSize;
48}
49void 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}
58
59void DataTable::ResetDataSectionBaseOffset( long dataSectionBaseOffset )
60{
61 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}
79
80void DataTable::Resolve( const ObjectModule &resolver, ResolveErrors &resolveErrors )
81{
82 BOOST_FOREACH( Schedule &schedule, schedules )
83 {
84 schedule.Resolve( resolver, resolveErrors );
85 }
86}
Note: See TracBrowser for help on using the repository browser.