source: dev/trunk/abdev/BasicCompiler_Common/src/DataTable.cpp@ 273

Last change on this file since 273 was 273, checked in by dai_9181, 17 years ago
File size: 1.5 KB
Line 
1#include "stdafx.h"
2
3#include <jenga/include/smoothie/Smoothie.h>
4
5#include <DataTable.h>
6
7#include <memory.h>
8#include <stdlib.h>
9
10int DataTable::AddBinary( const void *buffer, int size ){
11 int retSize = this->size;
12
13 Realloc( this->size + size );
14 memcpy( (char *)this->buffer + retSize, buffer, size );
15
16 return retSize;
17}
18int DataTable::Add( _int64 i64data ){
19 int retSize = size;
20 AddBinary( &i64data, sizeof( _int64 ) );
21 return retSize;
22}
23int DataTable::Add( int i32data ){
24 int retSize = size;
25 AddBinary( &i32data, sizeof( int ) );
26 return retSize;
27}
28int DataTable::Add( double dbl ){
29 int retSize = size;
30 AddBinary( &dbl, sizeof( double ) );
31 return retSize;
32}
33int DataTable::Add( float flt ){
34 int retSize = size;
35 AddBinary( &flt, sizeof( float ) );
36 return retSize;
37}
38int DataTable::AddString( const char *str, int length ){
39 int retSize = size;
40
41 if( Smoothie::IsUnicode() ){
42 //Shift-JIS → Unicode
43 int size = MultiByteToWideChar(
44 CP_ACP,
45 0,
46 str, length + 1,
47 NULL, 0 ) * 2;
48
49 LPWSTR pwstr = (LPWSTR)malloc( size );
50
51 MultiByteToWideChar(
52 CP_ACP,
53 0,
54 str, length + 1,
55 pwstr, length + 1 );
56
57 AddBinary( pwstr, size );
58
59 free( pwstr );
60 }
61 else{
62 AddBinary( str, length + 1 );
63 }
64
65 return retSize;
66}
67int DataTable::AddString( const char *str ){
68 int retSize = size;
69 AddString( str, lstrlen( str ) );
70 return retSize;
71}
72
73const void *DataTable::GetPtr() const
74{
75 return buffer;
76}
77int DataTable::GetSize() const
78{
79 return size;
80}
Note: See TracBrowser for help on using the repository browser.