431 |
* |
* |
432 |
* Returns the unique identifier of the original C/C++ member instance of |
* Returns the unique identifier of the original C/C++ member instance of |
433 |
* your C++ class. It is important to know that this unique identifier is |
* your C++ class. It is important to know that this unique identifier is |
434 |
* not generated particularly for Member objects. That means no matter how |
* not meant to be unique for Member instances themselves, but it is rather |
435 |
* many individual Member objects are created, as long as they are |
* meant to be unique for the original native C/C++ data these Member |
436 |
* representing the same member variable of the same original native |
* instances are representing. So that means no matter how many individual |
437 |
|
* Member objects are created, as long as they are representing the same |
438 |
|
* original native member variable of the same original native |
439 |
* instance of your C++ class, then all those separately created Member |
* instance of your C++ class, then all those separately created Member |
440 |
* objects return the same unique identifier here. |
* objects return the same unique identifier here. |
441 |
* |
* |
2082 |
setIntValue(object, atoll(value.c_str())); |
setIntValue(object, atoll(value.c_str())); |
2083 |
else if (type.isReal()) |
else if (type.isReal()) |
2084 |
setRealValue(object, atof(value.c_str())); |
setRealValue(object, atof(value.c_str())); |
2085 |
else if (type.isBool()) |
else if (type.isBool()) { |
2086 |
setBoolValue(object, atof(value.c_str())); |
String val = toLowerCase(value); |
2087 |
else if (type.isEnum()) |
if (val == "true" || val == "yes" || val == "1") |
2088 |
|
setBoolValue(object, true); |
2089 |
|
else if (val == "false" || val == "no" || val == "0") |
2090 |
|
setBoolValue(object, false); |
2091 |
|
else |
2092 |
|
setBoolValue(object, atof(value.c_str())); |
2093 |
|
} else if (type.isEnum()) |
2094 |
setEnumValue(object, atoll(value.c_str())); |
setEnumValue(object, atoll(value.c_str())); |
2095 |
else |
else |
2096 |
throw Exception("Not a primitive data type"); |
throw Exception("Not a primitive data type"); |
2286 |
// *************** Exception *************** |
// *************** Exception *************** |
2287 |
// * |
// * |
2288 |
|
|
2289 |
|
Exception::Exception() { |
2290 |
|
} |
2291 |
|
|
2292 |
|
Exception::Exception(String format, ...) { |
2293 |
|
va_list arg; |
2294 |
|
va_start(arg, format); |
2295 |
|
Message = assemble(format, arg); |
2296 |
|
va_end(arg); |
2297 |
|
} |
2298 |
|
|
2299 |
|
Exception::Exception(String format, va_list arg) { |
2300 |
|
Message = assemble(format, arg); |
2301 |
|
} |
2302 |
|
|
2303 |
/** @brief Print exception message to stdout. |
/** @brief Print exception message to stdout. |
2304 |
* |
* |
2305 |
* Prints the message of this Exception to the currently defined standard |
* Prints the message of this Exception to the currently defined standard |
2309 |
std::cout << "Serialization::Exception: " << Message << std::endl; |
std::cout << "Serialization::Exception: " << Message << std::endl; |
2310 |
} |
} |
2311 |
|
|
2312 |
|
String Exception::assemble(String format, va_list arg) { |
2313 |
|
char* buf = NULL; |
2314 |
|
vasprintf(&buf, format.c_str(), arg); |
2315 |
|
String s = buf; |
2316 |
|
free(buf); |
2317 |
|
return s; |
2318 |
|
} |
2319 |
|
|
2320 |
} // namespace Serialization |
} // namespace Serialization |