PARTONS/ElementaryUtils
|
Basic utility softwares (Logger, threads, etc)
|
A complex object to handle different simple types in a uniform way. More...
Public Member Functions | |
template<class T > | |
GenericType (const T &value) | |
Construct a GenericType object from any simple type. More... | |
virtual | ~GenericType () |
Default destructor. More... | |
GenericType (const GenericType &other) | |
Copy constructor. More... | |
double | toDouble () const |
Convert stream to double. More... | |
int | toInt () const |
Concert stream to integer. More... | |
unsigned int | toUInt () const |
Convert stream to unsigned integer. More... | |
bool | toBoolean () const |
Convert stream to boolean. More... | |
short | toShort () const |
Convert stream to short. More... | |
unsigned short | toUShort () const |
Convert stream to unsigned short. More... | |
size_t | toSize_t () const |
std::vector< double > | toVectorDouble () const |
std::vector< int > | toVectorInt () const |
std::string | getString () const |
Convert stream to string. More... | |
GenericType & | operator= (const GenericType &rhs) |
void | setValue (const GenericType &value) |
Private Member Functions | |
bool | operator== (const GenericType &right) const |
Disallow comparisons between GenericTypes. More... | |
bool | operator!= (const GenericType &right) const |
Private Attributes | |
std::stringstream | m_stream |
stream to store serialized simple type More... | |
A complex object to handle different simple types in a uniform way.
Simple types considered: double, int, unsigned int, boolean, short, unsigned short, string, etc. Various simple types are stored into a unique stream, providing a way to handle a generic type. Each simple type can be retrieved from the stream using an appropriate method. For example toInt() or toDouble() return respectively int or double variables.
Warning: a generic type object can be defined from any class, but the adequate conversion function may have to be added.
|
inline |
Construct a GenericType object from any simple type.
value |
|
virtual |
Default destructor.
ElemUtils::GenericType::GenericType | ( | const GenericType & | other | ) |
Copy constructor.
other |
std::string ElemUtils::GenericType::getString | ( | ) | const |
Convert stream to string.
|
private |
GenericType & ElemUtils::GenericType::operator= | ( | const GenericType & | rhs | ) |
|
private |
Disallow comparisons between GenericTypes.
void ElemUtils::GenericType::setValue | ( | const GenericType & | value | ) |
bool ElemUtils::GenericType::toBoolean | ( | ) | const |
Convert stream to boolean.
double ElemUtils::GenericType::toDouble | ( | ) | const |
Convert stream to double.
int ElemUtils::GenericType::toInt | ( | ) | const |
Concert stream to integer.
short ElemUtils::GenericType::toShort | ( | ) | const |
Convert stream to short.
size_t ElemUtils::GenericType::toSize_t | ( | ) | const |
unsigned int ElemUtils::GenericType::toUInt | ( | ) | const |
Convert stream to unsigned integer.
unsigned short ElemUtils::GenericType::toUShort | ( | ) | const |
Convert stream to unsigned short.
std::vector< double > ElemUtils::GenericType::toVectorDouble | ( | ) | const |
std::vector< int > ElemUtils::GenericType::toVectorInt | ( | ) | const |
|
private |
stream to store serialized simple type