#include #include #pragma once namespace Jenga{ namespace Common{ class Binary { int allocateSize; char *buffer; int size; // XMLシリアライズ用 private: friend class boost::serialization::access; BOOST_SERIALIZATION_SPLIT_MEMBER(); template void load(Archive& ar, const unsigned int version) { std::string _buffer; ar & BOOST_SERIALIZATION_NVP( _buffer ); ar & BOOST_SERIALIZATION_NVP( size ); // 読み込み後の処理 Realloc( size ); for( int i=0; i= 'a' ) ? ( _buffer[i*3] - 'a' + 0x0a ) : ( _buffer[i*3] - '0' ) ) * 0x10; ULONG_PTR l2 = ( _buffer[i*3+1] >= 'a' ) ? ( _buffer[i*3+1] - 'a' + 0x0a ) : ( _buffer[i*3+1] - '0' ); ULONG_PTR l = l1 + l2; buffer[i] = static_cast(l); } } template void save(Archive& ar, const unsigned int version) const { // 保存準備 char *tempCode = (char *)calloc( (size+1) * 3, 1 ); for( int i=0; ibuffer + pos, buffer, size ); } void Overwrite( int pos, char c ) { buffer[pos] = c; } void Overwrite( int pos, long newLongValue ) { *(long *)( buffer + pos ) = newLongValue; } void Overwrite( int pos, _int64 newInt64Value ) { *(_int64 *)( buffer + pos ) = newInt64Value; } void Put( const char *buffer, int size ) { Realloc( this->size + size ); memcpy( this->buffer + this->size, buffer, size ); this->size += size; } void Put( const Binary &binary ) { Put( binary.GetBuffer(), binary.GetSize() ); } void Put( double dbl ) { Put( (const char *)(&dbl), sizeof(double) ); } void Put( float flt ) { Put( (const char *)(&flt), sizeof(float) ); } void Put( _int64 i64data ) { Put( (const char *)(&i64data), sizeof(_int64) ); } void Put( long l ) { Realloc( size + sizeof(long) ); *((long *)(buffer+size))=l; size += sizeof(long); } void Put( short s ) { Realloc( size + sizeof(short) ); *((short *)(buffer+size))=s; size += sizeof(short); } void Put( char c ) { Realloc( size + 1 ); buffer[size++] = c; } }; }}