2 #ifndef GAUDIKERNEL_DATATYPES_H
3 #define GAUDIKERNEL_DATATYPES_H
29 OBJECT_REF, CONTAINED_REF,
POINTER, OBJECT_ADDR,
30 LONG_STRING, LONG_NTCHAR, LONGLONG, ULONGLONG
33 static Type ID(
const bool) {
return BOOL; }
35 static Type ID(
const char) {
return CHAR; }
37 static Type ID(
const short) {
return SHORT; }
39 static Type ID(
const int) {
return INT; }
41 static Type ID(
const long) {
return LONG; }
43 static Type ID(
const long long) {
return LONGLONG; }
45 static Type ID(
const unsigned char) {
return UCHAR; }
47 static Type ID(
const unsigned short) {
return USHORT; }
49 static Type ID(
const unsigned int) {
return UINT; }
51 static Type ID(
const unsigned long) {
return ULONG; }
53 static Type ID(
const unsigned long long) {
return ULONGLONG; }
55 static Type ID(
const float) {
return FLOAT; }
57 static Type ID(
const double) {
return DOUBLE; }
59 static Type ID(
const std::string&) {
return STRING; }
61 static Type ID(
const char*) {
return NTCHAR; }
65 static Type ID(
const void*) {
return POINTER; }
72 static Type ID(
const std::type_info& typ ) {
73 if ( typ ==
typeid(
unsigned char) )
75 else if ( typ ==
typeid(
unsigned short) )
77 else if ( typ ==
typeid(
unsigned int) )
79 else if ( typ ==
typeid(
unsigned long) )
81 else if ( typ ==
typeid(
unsigned long long) )
83 else if ( typ ==
typeid(
char) )
85 else if ( typ ==
typeid(
short) )
87 else if ( typ ==
typeid(
int) )
89 else if ( typ ==
typeid(
long) )
91 else if ( typ ==
typeid(
long long) )
93 else if ( typ ==
typeid(
bool) )
95 else if ( typ ==
typeid(
float) )
97 else if ( typ ==
typeid(
double) )
99 else if ( typ ==
typeid(std::string) )
101 else if ( typ ==
typeid(
char*) )
106 return CONTAINED_REF;
109 else if ( typ ==
typeid(
void*) )
116 static const std::type_info&
type(
long typ ) {
119 return typeid(
unsigned char);
121 return typeid(
unsigned short);
123 return typeid(
unsigned int);
125 return typeid(
unsigned long);
127 return typeid(
unsigned long long);
131 return typeid(short);
137 return typeid(
long long);
141 return typeid(float);
143 return typeid(double);
145 return typeid(std::string);
147 return typeid(std::string);
149 return typeid(
char*);
151 return typeid(
char*);
161 return typeid(
void*);
169 return sizeof(
unsigned char);
171 return sizeof(
unsigned short);
173 return sizeof(
unsigned int);
175 return sizeof(
unsigned long);
177 return sizeof(
unsigned long long);
181 return sizeof(short);
187 return sizeof(
long long);
191 return sizeof(float);
193 return sizeof(double);
195 return sizeof(std::string);
197 return sizeof(std::string);
199 return sizeof(
char*);
201 return sizeof(
char*);
213 static long size(
const std::type_info& typ ) {
214 return size( ID(typ) );
218 static int copy(
void* tar,
const void* src,
long typ,
int numObj ) {
220 case UCHAR: numObj *=
sizeof(
unsigned char);
break;
221 case USHORT: numObj *=
sizeof(
unsigned short);
break;
222 case UINT: numObj *=
sizeof(
unsigned int);
break;
223 case ULONG: numObj *=
sizeof(
unsigned long);
break;
224 case ULONGLONG: numObj *=
sizeof(
unsigned long long);
break;
225 case CHAR: numObj *=
sizeof(char);
break;
226 case SHORT: numObj *=
sizeof(short);
break;
227 case INT: numObj *=
sizeof(int);
break;
228 case LONG: numObj *=
sizeof(long);
break;
229 case LONGLONG: numObj *=
sizeof(
long long);
break;
230 case BOOL: numObj *=
sizeof(bool);
break;
231 case FLOAT: numObj *=
sizeof(float);
break;
232 case DOUBLE: numObj *=
sizeof(double);
break;
234 default: numObj *= 0;
break;
236 memcpy(tar, src, numObj);
241 static std::string name(
long typ);
243 static std::string name(
const std::type_info& typ);
245 static Type idByName(
const std::string& typ );
247 static const std::type_info& typeByName(
const std::string& typ );
249 #endif // GAUDIKERNEL_DATATYPES_H