4 #define __STDC_FORMAT_MACROS
11 this->m_dataType = TYPE_NOTYPE;
15 this->m_dataType = TYPE_U8;
16 this->m_val.u8Val = val;
19 PolyType::operator
U8() {
21 return this->m_val.u8Val;
26 val = this->m_val.u8Val;
30 return (TYPE_U8 == this->m_dataType);
34 this->m_dataType = TYPE_U8;
35 this->m_val.u8Val = other;
42 this->m_dataType = TYPE_I8;
43 this->m_val.i8Val = val;
46 PolyType::operator
I8() {
48 return this->m_val.i8Val;
53 val = this->m_val.i8Val;
57 return (TYPE_I8 == this->m_dataType);
61 this->m_dataType = TYPE_I8;
62 this->m_val.i8Val = other;
71 this->m_dataType = TYPE_U16;
72 this->m_val.u16Val = val;
75 PolyType::operator U16() {
77 return this->m_val.u16Val;
82 val = this->m_val.u16Val;
85 bool PolyType::isU16() {
86 return (TYPE_U16 == this->m_dataType);
90 this->m_dataType = TYPE_U16;
91 this->m_val.u16Val = other;
98 this->m_dataType = TYPE_I16;
99 this->m_val.i16Val = val;
102 PolyType::operator I16() {
104 return this->m_val.i16Val;
109 val = this->m_val.i16Val;
112 bool PolyType::isI16() {
113 return (TYPE_I16 == this->m_dataType);
117 this->m_dataType = TYPE_I16;
118 this->m_val.i16Val = other;
129 this->m_dataType = TYPE_U32;
130 this->m_val.u32Val = val;
133 PolyType::operator U32() {
135 return this->m_val.u32Val;
140 val = this->m_val.u32Val;
143 bool PolyType::isU32() {
144 return (TYPE_U32 == this->m_dataType);
148 this->m_dataType = TYPE_U32;
149 this->m_val.u32Val = other;
156 this->m_dataType = TYPE_I32;
157 this->m_val.i32Val = val;
160 PolyType::operator I32() {
162 return this->m_val.i32Val;
167 val = this->m_val.i32Val;
170 bool PolyType::isI32() {
171 return (TYPE_I32 == this->m_dataType);
175 this->m_dataType = TYPE_I32;
176 this->m_val.i32Val = other;
186 this->m_dataType = TYPE_U64;
187 this->m_val.u64Val = val;
190 PolyType::operator
U64() {
192 return this->m_val.u64Val;
197 val = this->m_val.u64Val;
200 bool PolyType::isU64() {
201 return (TYPE_U64 == this->m_dataType);
205 this->m_dataType = TYPE_U64;
206 this->m_val.u64Val = other;
213 this->m_dataType = TYPE_I64;
214 this->m_val.i64Val = val;
217 PolyType::operator I64() {
219 return this->m_val.i64Val;
224 val = this->m_val.i64Val;
227 bool PolyType::isI64() {
228 return (TYPE_I64 == this->m_dataType);
232 this->m_dataType = TYPE_I64;
233 this->m_val.i64Val = other;
242 this->m_dataType = TYPE_F64;
243 this->m_val.f64Val = val;
246 PolyType::operator F64() {
248 return this->m_val.f64Val;
253 val = this->m_val.f64Val;
256 bool PolyType::isF64() {
257 return (TYPE_F64 == this->m_dataType);
261 this->m_dataType = TYPE_F64;
262 this->m_val.f64Val = other;
268 this->m_dataType = TYPE_F32;
269 this->m_val.f32Val = val;
272 PolyType::operator
F32() {
274 return this->m_val.f32Val;
279 val = this->m_val.f32Val;
283 return (TYPE_F32 == this->m_dataType);
287 this->m_dataType = TYPE_F32;
288 this->m_val.f32Val = other;
293 this->m_dataType = TYPE_BOOL;
294 this->m_val.boolVal = val;
297 PolyType::operator bool() {
298 FW_ASSERT(TYPE_BOOL == this->m_dataType);
299 return this->m_val.boolVal;
303 FW_ASSERT(TYPE_BOOL == this->m_dataType);
304 val = this->m_val.boolVal;
308 return (TYPE_BOOL == this->m_dataType);
312 this->m_dataType = TYPE_BOOL;
313 this->m_val.boolVal = other;
318 this->m_dataType = TYPE_PTR;
319 this->m_val.ptrVal = val;
322 PolyType::operator
void*() {
324 return this->m_val.ptrVal;
329 val = this->m_val.ptrVal;
333 return (TYPE_PTR == this->m_dataType);
337 this->m_dataType = TYPE_PTR;
338 this->m_val.ptrVal = other;
343 this->m_dataType = original.m_dataType;
344 this->m_val = original.m_val;
350 this->m_dataType = src.m_dataType;
351 this->m_val = src.m_val;
361 if (this->m_dataType != other.m_dataType) {
365 bool valIsEqual =
false;
366 switch (this->m_dataType) {
368 valIsEqual = (this->m_val.u8Val == other.m_val.u8Val);
371 valIsEqual = (this->m_val.i8Val == other.m_val.i8Val);
375 valIsEqual = (this->m_val.u16Val == other.m_val.u16Val);
378 valIsEqual = (this->m_val.i16Val == other.m_val.i16Val);
383 valIsEqual = (this->m_val.u32Val == other.m_val.u32Val);
386 valIsEqual = (this->m_val.i32Val == other.m_val.i32Val);
391 valIsEqual = (this->m_val.u64Val == other.m_val.u64Val);
394 valIsEqual = (this->m_val.i64Val == other.m_val.i64Val);
398 valIsEqual = (this->m_val.boolVal == other.m_val.boolVal);
401 valIsEqual = (this->m_val.ptrVal == other.m_val.ptrVal);
420 if (this->m_dataType != other.m_dataType) {
425 switch (this->m_dataType) {
427 result = (this->m_val.u8Val < other.m_val.u8Val);
430 result = (this->m_val.i8Val < other.m_val.i8Val);
434 result = (this->m_val.u16Val < other.m_val.u16Val);
437 result = (this->m_val.i16Val < other.m_val.i16Val);
442 result = (this->m_val.u32Val < other.m_val.u32Val);
445 result = (this->m_val.i32Val < other.m_val.i32Val);
450 result = (this->m_val.u64Val < other.m_val.u64Val);
453 result = (this->m_val.i64Val < other.m_val.i64Val);
458 result = (this->m_val.f64Val < other.m_val.f64Val);
462 result = (this->m_val.f32Val < other.m_val.f32Val);
465 result = (this->m_val.ptrVal < other.m_val.ptrVal);
480 return other.operator<(*this);
484 return (this->
operator>(other)) || (this->
operator==(other));
488 return (this->
operator<(other)) || (this->
operator==(other));
499 switch (this->m_dataType) {
501 stat = buffer.
serialize(this->m_val.u8Val);
504 stat = buffer.
serialize(this->m_val.i8Val);
508 stat = buffer.
serialize(this->m_val.u16Val);
511 stat = buffer.
serialize(this->m_val.i16Val);
516 stat = buffer.
serialize(this->m_val.u32Val);
519 stat = buffer.
serialize(this->m_val.i32Val);
524 stat = buffer.
serialize(this->m_val.u64Val);
527 stat = buffer.
serialize(this->m_val.i64Val);
532 stat = buffer.
serialize(this->m_val.f64Val);
536 stat = buffer.
serialize(this->m_val.f32Val);
539 stat = buffer.
serialize(this->m_val.boolVal);
542 stat = buffer.
serialize(this->m_val.ptrVal);
560 this->m_dataType =
static_cast<Type
>(des);
562 switch (this->m_dataType) {
601 #if FW_SERIALIZABLE_TO_STRING || BUILD_UT
603 void PolyType::toString(
StringBase& dest)
const {
604 this->toString(dest,
false);
607 void PolyType::toString(StringBase& dest,
bool append)
const {
609 switch (this->m_dataType) {
611 (void)snprintf(valString,
sizeof(valString),
"%" PRIu8
" ", this->m_val.u8Val);
614 (void)snprintf(valString,
sizeof(valString),
"%" PRId8
" ", this->m_val.i8Val);
618 (void)snprintf(valString,
sizeof(valString),
"%" PRIu16
" ", this->m_val.u16Val);
621 (void)snprintf(valString,
sizeof(valString),
"%" PRId16
" ", this->m_val.i16Val);
626 (void)snprintf(valString,
sizeof(valString),
"%" PRIu32
" ", this->m_val.u32Val);
629 (void)snprintf(valString,
sizeof(valString),
"%" PRId32
" ", this->m_val.i32Val);
634 (void)snprintf(valString,
sizeof(valString),
"%" PRIu64
" ", this->m_val.u64Val);
637 (void)snprintf(valString,
sizeof(valString),
"%" PRId64
" ", this->m_val.i64Val);
642 (void)snprintf(valString,
sizeof(valString),
"%lg ", this->m_val.f64Val);
646 (void)snprintf(valString,
sizeof(valString),
"%g ", this->m_val.f32Val);
649 (void)snprintf(valString,
sizeof(valString),
"%s ", this->m_val.boolVal ?
"T" :
"F");
652 (void)snprintf(valString,
sizeof(valString),
"%p ", this->m_val.ptrVal);
655 (void)snprintf(valString,
sizeof(valString),
"%s ",
"NT");
660 valString[
sizeof(valString) - 1] = 0;
int8_t I8
8-bit signed integer
float F32
32-bit floating point
uint8_t U8
8-bit unsigned integer
PlatformAssertArgType FwAssertArgType
bool isBool()
bool checker
bool operator<(const PolyType &other) const
PolyType operator<.
bool operator>=(const PolyType &other) const
PolyType operator>=.
bool isPtr()
void* checker
bool operator>(const PolyType &other) const
PolyType operator>
bool operator==(const PolyType &other) const
PolyType operator==.
PolyType()
default constructor
SerializeStatus deserialize(SerializeBufferBase &buffer)
Deserialize function.
SerializeStatus serialize(SerializeBufferBase &buffer) const
Serialize function.
bool operator<=(const PolyType &other) const
PolyType operator<=.
bool operator!=(const PolyType &other) const
PolyType operator!=.
PolyType & operator=(U8 val)
U8 operator=.
virtual ~PolyType()
destructor
void get(U8 &val)
U8 accessor.
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
SerializeStatus
forward declaration for string
@ FW_DESERIALIZE_FORMAT_ERROR
Deserialization data had incorrect values (unexpected data types)
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
@ FW_SERIALIZE_FORMAT_ERROR
Data was the wrong format (e.g. wrong packet type)