4 #define __STDC_FORMAT_MACROS
12 this->m_dataType = TYPE_NOTYPE;
16 this->m_dataType = TYPE_U8;
17 this->m_val.u8Val = val;
20 PolyType::operator
U8() {
22 return this->m_val.u8Val;
27 val = this->m_val.u8Val;
31 return (TYPE_U8 == this->m_dataType);
35 this->m_dataType = TYPE_U8;
36 this->m_val.u8Val = other;
43 this->m_dataType = TYPE_I8;
44 this->m_val.i8Val = val;
47 PolyType::operator
I8() {
49 return this->m_val.i8Val;
54 val = this->m_val.i8Val;
58 return (TYPE_I8 == this->m_dataType);
62 this->m_dataType = TYPE_I8;
63 this->m_val.i8Val = other;
72 this->m_dataType = TYPE_U16;
73 this->m_val.u16Val = val;
76 PolyType::operator U16() {
78 return this->m_val.u16Val;
83 val = this->m_val.u16Val;
86 bool PolyType::isU16() {
87 return (TYPE_U16 == this->m_dataType);
91 this->m_dataType = TYPE_U16;
92 this->m_val.u16Val = other;
99 this->m_dataType = TYPE_I16;
100 this->m_val.i16Val = val;
103 PolyType::operator I16() {
105 return this->m_val.i16Val;
110 val = this->m_val.i16Val;
113 bool PolyType::isI16() {
114 return (TYPE_I16 == this->m_dataType);
118 this->m_dataType = TYPE_I16;
119 this->m_val.i16Val = other;
130 this->m_dataType = TYPE_U32;
131 this->m_val.u32Val = val;
134 PolyType::operator U32() {
136 return this->m_val.u32Val;
141 val = this->m_val.u32Val;
144 bool PolyType::isU32() {
145 return (TYPE_U32 == this->m_dataType);
149 this->m_dataType = TYPE_U32;
150 this->m_val.u32Val = other;
157 this->m_dataType = TYPE_I32;
158 this->m_val.i32Val = val;
161 PolyType::operator I32() {
163 return this->m_val.i32Val;
168 val = this->m_val.i32Val;
171 bool PolyType::isI32() {
172 return (TYPE_I32 == this->m_dataType);
176 this->m_dataType = TYPE_I32;
177 this->m_val.i32Val = other;
187 this->m_dataType = TYPE_U64;
188 this->m_val.u64Val = val;
191 PolyType::operator
U64() {
193 return this->m_val.u64Val;
198 val = this->m_val.u64Val;
201 bool PolyType::isU64() {
202 return (TYPE_U64 == this->m_dataType);
206 this->m_dataType = TYPE_U64;
207 this->m_val.u64Val = other;
214 this->m_dataType = TYPE_I64;
215 this->m_val.u64Val = val;
218 PolyType::operator I64() {
220 return this->m_val.i64Val;
225 val = this->m_val.i64Val;
228 bool PolyType::isI64() {
229 return (TYPE_I64 == this->m_dataType);
233 this->m_dataType = TYPE_I64;
234 this->m_val.i64Val = other;
243 this->m_dataType = TYPE_F64;
244 this->m_val.f64Val = val;
247 PolyType::operator F64() {
249 return this->m_val.f64Val;
254 val = this->m_val.f64Val;
257 bool PolyType::isF64() {
258 return (TYPE_F64 == this->m_dataType);
262 this->m_dataType = TYPE_F64;
263 this->m_val.f64Val = other;
269 this->m_dataType = TYPE_F32;
270 this->m_val.f32Val = val;
273 PolyType::operator
F32() {
275 return this->m_val.f32Val;
280 val = this->m_val.f32Val;
284 return (TYPE_F32 == this->m_dataType);
288 this->m_dataType = TYPE_F32;
289 this->m_val.f32Val = other;
294 this->m_dataType = TYPE_BOOL;
295 this->m_val.boolVal = val;
298 PolyType::operator bool() {
299 FW_ASSERT(TYPE_BOOL == this->m_dataType);
300 return this->m_val.boolVal;
304 FW_ASSERT(TYPE_BOOL == this->m_dataType);
305 val = this->m_val.boolVal;
309 return (TYPE_BOOL == this->m_dataType);
313 this->m_dataType = TYPE_BOOL;
314 this->m_val.boolVal = other;
319 this->m_dataType = TYPE_PTR;
320 this->m_val.ptrVal = val;
323 PolyType::operator
void*() {
325 return this->m_val.ptrVal;
330 val = this->m_val.ptrVal;
334 return (TYPE_PTR == this->m_dataType);
338 this->m_dataType = TYPE_PTR;
339 this->m_val.ptrVal = other;
344 this->m_dataType = original.m_dataType;
345 this->m_val = original.m_val;
352 this->m_dataType = src.m_dataType;
353 this->m_val = src.m_val;
364 if (this->m_dataType != other.m_dataType) {
368 bool valIsEqual =
false;
369 switch (this->m_dataType) {
371 valIsEqual = (this->m_val.u8Val == other.m_val.u8Val);
374 valIsEqual = (this->m_val.i8Val == other.m_val.i8Val);
378 valIsEqual = (this->m_val.u16Val == other.m_val.u16Val);
381 valIsEqual = (this->m_val.i16Val == other.m_val.i16Val);
386 valIsEqual = (this->m_val.u32Val == other.m_val.u32Val);
389 valIsEqual = (this->m_val.i32Val == other.m_val.i32Val);
394 valIsEqual = (this->m_val.u64Val == other.m_val.u64Val);
397 valIsEqual = (this->m_val.i64Val == other.m_val.i64Val);
401 valIsEqual = (this->m_val.boolVal == other.m_val.boolVal);
404 valIsEqual = (this->m_val.ptrVal == other.m_val.ptrVal);
425 if (this->m_dataType != other.m_dataType) {
430 switch (this->m_dataType) {
432 result = (this->m_val.u8Val < other.m_val.u8Val);
435 result = (this->m_val.i8Val < other.m_val.i8Val);
439 result = (this->m_val.u16Val < other.m_val.u16Val);
442 result = (this->m_val.i16Val < other.m_val.i16Val);
447 result = (this->m_val.u32Val < other.m_val.u32Val);
450 result = (this->m_val.i32Val < other.m_val.i32Val);
455 result = (this->m_val.u64Val < other.m_val.u64Val);
458 result = (this->m_val.i64Val < other.m_val.i64Val);
463 result = (this->m_val.f64Val < other.m_val.f64Val);
467 result = (this->m_val.f32Val < other.m_val.f32Val);
470 result = (this->m_val.ptrVal < other.m_val.ptrVal);
486 return other.operator<(*this);
490 return (this->
operator>(other)) || (this->
operator==(other));
494 return (this->
operator<(other)) || (this->
operator==(other));
507 switch (this->m_dataType) {
509 stat = buffer.
serialize(this->m_val.u8Val);
512 stat = buffer.
serialize(this->m_val.i8Val);
516 stat = buffer.
serialize(this->m_val.u16Val);
519 stat = buffer.
serialize(this->m_val.i16Val);
524 stat = buffer.
serialize(this->m_val.u32Val);
527 stat = buffer.
serialize(this->m_val.i32Val);
532 stat = buffer.
serialize(this->m_val.u64Val);
535 stat = buffer.
serialize(this->m_val.i64Val);
538 stat = buffer.
serialize(this->m_val.f64Val);
542 stat = buffer.
serialize(this->m_val.f32Val);
545 stat = buffer.
serialize(this->m_val.boolVal);
548 stat = buffer.
serialize(this->m_val.ptrVal);
566 this->m_dataType =
static_cast<Type
>(des);
568 switch (this->m_dataType) {
606 #if FW_OBJECT_TO_STRING
608 void PolyType::toString(
StringBase& dest)
const {
609 this->toString(dest,
false);
612 void PolyType::toString(StringBase& dest,
bool append)
const {
615 switch (this->m_dataType) {
617 (void) snprintf(valString,
sizeof(valString),
"%" PRIu8
" ", this->m_val.u8Val);
620 (void) snprintf(valString,
sizeof(valString),
"%" PRId8
" ", this->m_val.i8Val);
624 (void) snprintf(valString,
sizeof(valString),
"%" PRIu16
" ", this->m_val.u16Val);
627 (void) snprintf(valString,
sizeof(valString),
"%" PRId16
" ", this->m_val.i16Val);
632 (void) snprintf(valString,
sizeof(valString),
"%" PRIu32
" ", this->m_val.u32Val);
635 (void) snprintf(valString,
sizeof(valString),
"%" PRId32
" ", this->m_val.i32Val);
640 (void) snprintf(valString,
sizeof(valString),
"%" PRIu64
" ", this->m_val.u64Val);
643 (void) snprintf(valString,
sizeof(valString),
"%" PRId64
" ", this->m_val.i64Val);
648 (void) snprintf(valString,
sizeof(valString),
"%lg ", this->m_val.f64Val);
652 (void) snprintf(valString,
sizeof(valString),
"%g ", this->m_val.f32Val);
655 (void) snprintf(valString,
sizeof(valString),
"%s ", this->m_val.boolVal?
"T":
"F");
658 (void) snprintf(valString,
sizeof(valString),
"%p ", this->m_val.ptrVal);
661 (void) snprintf(valString,
sizeof(valString),
"%s ",
"NT");
666 valString[
sizeof(valString)-1] = 0;