cumbia 1.x
general purpose multi threaded library
|
CuVariant class acts like a union for the cumbia data types. More...
#include <cuvariant.h>
Public Types | |
enum | DataFormat { FormatInvalid = 0 , Scalar , Vector , Matrix , EndFormatTypes = 32 } |
The DataFormat enum lists the different data formats supported by CuVariant. More... | |
enum | DataType { TypeInvalid = 0 , Short , UShort , Int , UInt , LongInt , LongLongInt , LongUInt , LongLongUInt , Float , Double , LongDouble , Boolean , String , VoidPtr , Char , UChar , EndDataTypes = 64 } |
The DataType enum lists the different data types that can be held by CuVariant. More... | |
Public Member Functions | |
CuVariant (const size_t size, DataFormat df, DataType dt) | |
virtual | ~CuVariant () |
the class destructor More... | |
CuVariant (char c) | |
CuVariant (unsigned char uc) | |
CuVariant (short int i) | |
CuVariant (short unsigned int u) | |
CuVariant (int i) | |
builds a CuVariant holding the specified integer More... | |
CuVariant (unsigned int ui) | |
builds a CuVariant holding the specified unsigned integer More... | |
CuVariant (long int li) | |
builds a CuVariant holding the specified long integer More... | |
CuVariant (long long int li) | |
CuVariant (unsigned long int lui) | |
builds a CuVariant holding the specified unsigned long integer More... | |
CuVariant (unsigned long long int ului) | |
CuVariant (float d) | |
builds a CuVariant holding the specified float More... | |
CuVariant (double d) | |
builds a CuVariant holding the specified double More... | |
CuVariant (long double ld) | |
builds a CuVariant holding the specified long double More... | |
CuVariant (bool b) | |
builds a CuVariant holding the specified boolean value More... | |
CuVariant (const std::string &s) | |
builds a CuVariant holding the specified std::string More... | |
CuVariant (const char *s) | |
builds a CuVariant holding the specified constant char string More... | |
CuVariant (void *ptr) | |
builds a CuVariant storing the void * pointer passed as argument More... | |
CuVariant (const std::vector< unsigned char > &m, size_t dimx, size_t dimy) | |
CuVariant (const std::vector< char > &m, size_t dimx, size_t dimy) | |
CuVariant (const std::vector< short int > &i, size_t dimx, size_t dimy) | |
CuVariant (const std::vector< short unsigned int > &si, size_t dimx, size_t dimy) | |
CuVariant (const std::vector< int > &vi, size_t dimx, size_t dimy) | |
CuVariant (const std::vector< unsigned int > &ui, size_t dimx, size_t dimy) | |
CuVariant (const std::vector< long int > &li, size_t dimx, size_t dimy) | |
CuVariant (const std::vector< long long int > &lli, size_t dimx, size_t dimy) | |
CuVariant (const std::vector< long unsigned int > &lui, size_t dimx, size_t dimy) | |
CuVariant (const std::vector< long long unsigned int > &llui, size_t dimx, size_t dimy) | |
CuVariant (const std::vector< float > &vf, size_t dimx, size_t dimy) | |
CuVariant (const std::vector< double > &vd, size_t dimx, size_t dimy) | |
CuVariant (const std::vector< long double > &vd, size_t dimx, size_t dimy) | |
CuVariant (const std::vector< bool > &vb, size_t dimx, size_t dimy) | |
CuVariant (const std::vector< std::string > &vs, size_t dimx, size_t dimy) | |
CuVariant (const std::vector< char > &c) | |
vector of char flavor More... | |
CuVariant (const std::vector< unsigned char > &uc) | |
vector of unsigned char flavor More... | |
CuVariant (const std::vector< short int > &i) | |
CuVariant (const std::vector< short unsigned int > &si) | |
CuVariant (const std::vector< int > &vi) | |
builds a CuVariant holding the specified vector of integers More... | |
CuVariant (const std::vector< unsigned int > &ui) | |
builds a CuVariant holding the specified vector of unsigned integers More... | |
CuVariant (const std::vector< long int > &li) | |
builds a CuVariant holding the specified vector of long integers More... | |
CuVariant (const std::vector< long long int > &lli) | |
CuVariant (const std::vector< long unsigned int > &lui) | |
CuVariant (const std::vector< long long unsigned int > &llui) | |
CuVariant (const std::vector< float > &vf) | |
builds a CuVariant holding the specified vector of float More... | |
CuVariant (const std::vector< double > &vd) | |
builds a CuVariant holding the specified vector of double More... | |
CuVariant (const std::vector< long double > &vd) | |
builds a CuVariant holding the specified vector of long double More... | |
CuVariant (const std::vector< bool > &vd) | |
builds a CuVariant holding the specified vector of booleans More... | |
CuVariant (const std::vector< std::string > &vd) | |
builds a CuVariant holding the specified vector of std::string More... | |
CuVariant (const std::vector< void * > &vptr) | |
builds a CuVariant holding the specified vector of void* pointers More... | |
CuVariant (const CuVariant &other) | |
copy constructor More... | |
CuVariant (CuVariant &&other) | |
move constructor More... | |
CuVariant () | |
Creates an empty (invalid) CuVariant. More... | |
template<typename T > | |
CuVariant (const T *p, size_t siz, DataFormat f, DataType t, int rows=1) | |
CuVariant & | operator= (const CuVariant &other) |
assignment operator, copies data from another CuVariant More... | |
CuVariant & | operator= (CuVariant &&other) |
move assignment operator, moves data from another source More... | |
bool | operator== (const CuVariant &other) const |
equality relational operator. Returns true if this CuVariant equals another one More... | |
bool | operator!= (const CuVariant &other) const |
returns the opposite result of the equality operator More... | |
DataFormat | getFormat () const |
get the format of the data stored More... | |
DataType | getType () const |
Returns the DataType stored by CuVariant. More... | |
size_t | getSize () const |
Returns the size of the data stored by the CuVariant. More... | |
size_t | get_dim_x () const |
size_t | get_dim_y () const |
bool | isInteger () const |
returns true if the stored data is an integer number More... | |
bool | isUnsignedType () const |
bool | isSignedType () const |
bool | isFloatingPoint () const |
returns true if the stored data is a floating point number More... | |
bool | isVoidPtr () const |
returns true if the data stored is a void * pointer More... | |
bool | isValid () const |
Returns whether the data stored by CuVariant is valid. More... | |
bool | isNull () const |
Returns whether the the data stored by CuVariant is NULL or not. More... | |
bool | isWNull () const |
std::vector< double > | toDoubleVector () const |
convert the stored data into a vector of double More... | |
std::vector< double > | dv () const |
std::vector< long double > | toLongDoubleVector () const |
convert the stored data into a vector of long double More... | |
std::vector< long double > | ldv () const |
std::vector< float > | toFloatVector () const |
convert the stored data into a vector of float More... | |
std::vector< float > | fv () const |
std::vector< int > | toIntVector () const |
convert the stored data into a vector of integers More... | |
std::vector< int > | iv () const |
std::vector< unsigned int > | toUIntVector () const |
convert the stored data into a vector of unsigned integers More... | |
std::vector< unsigned int > | uv () const |
std::vector< unsigned long long int > | toLongLongUIntVector () const |
convert the stored data into a vector of unsigned long long integers More... | |
std::vector< unsigned long long int > | ullv () const |
std::vector< long int > | toLongIntVector () const |
convert the stored data into a vector of long integers More... | |
std::vector< long int > | lv () const |
std::vector< long long int > | toLongLongIntVector () const |
std::vector< long long int > | llv () |
std::vector< unsigned long int > | toULongIntVector () const |
convert the stored data into a vector of unsigned integers More... | |
std::vector< unsigned long int > | ulv () const |
std::vector< bool > | toBoolVector () const |
convert the stored data into a vector of booleans More... | |
std::vector< bool > | bv () const |
std::vector< short > | toShortVector () const |
convert the stored data into a vector of short integers More... | |
std::vector< short > | siv () const |
std::vector< unsigned short > | toUShortVector () const |
convert the stored data into a vector of unsigned short integers More... | |
std::vector< unsigned short > | usv () const |
std::vector< char > | toCharVector () const |
convert the stored data into a vector of char More... | |
std::vector< char > | cv () const |
std::vector< unsigned char > | toUCharVector () const |
convert the stored data into a vector of unsigned char More... | |
std::vector< unsigned char > | ucv () const |
double | toDouble (bool *ok=nullptr) const |
convert the stored data into a double scalar More... | |
double | d () const |
long double | toLongDouble (bool *ok=nullptr) const |
convert the stored data into a long double scalar More... | |
long double | ld () const |
unsigned long int | toULongInt (bool *ok=nullptr) const |
convert the stored data into a scalar unsigned long number More... | |
unsigned long int | ul () const |
unsigned long long | toULongLongInt (bool *ok) const |
unsigned long long | ull () const |
long int | toLongInt (bool *ok=nullptr) const |
convert the stored data into a scalar long int More... | |
long int | l () const |
long long int | toLongLongInt (bool *ok=nullptr) const |
long long int | ll () const |
int | toInt (bool *ok=nullptr) const |
convert the stored data into a scalar integer More... | |
int | i () const |
unsigned int | toUInt (bool *ok=nullptr) const |
convert the stored data into a scalar unsigned integer More... | |
unsigned int | u () const |
unsigned short | toUShortInt (bool *ok=nullptr) const |
convert the stored data into a scalar unsigned short More... | |
unsigned short | us () const |
short | toShortInt (bool *ok=nullptr) const |
convert the stored data into a scalar signed short More... | |
short | si () const |
float | toFloat (bool *ok=nullptr) const |
convert the stored data into a scalar floating point number More... | |
float | f () const |
bool | toBool (bool *ok=nullptr) const |
convert the stored data into a scalar boolean More... | |
bool | b () const |
std::string | toString (bool *ok=nullptr, const char *format="") const |
Convert the stored value to a string representation. More... | |
std::string | s () const |
std::string | s (const char *fmt, bool *ok=nullptr) const |
std::vector< std::string > | toStringVector (bool *ok=nullptr) const |
std::vector< std::string > | toStringVector (const char *fmt) const |
std::vector< std::string > | toStringVector (const char *fmt, bool *ok) const |
convert the stored data into a vector of strings More... | |
std::vector< std::string > | sv () const |
std::vector< std::string > | sv (const char *fmt, bool *ok=nullptr) const |
double * | toDoubleP () const |
Returns the pointer to the data stored as double, or NULL if no data is stored or if the data type is wrong. More... | |
long double * | toLongDoubleP () const |
Returns the pointer to the data stored as long double, or NULL if no data is stored or if the data type is wrong. More... | |
long int * | toLongIntP () const |
Returns the pointer to the data stored as long int, or NULL if no data is stored or if the data type is wrong. More... | |
long long int * | toLongLongIntP () const |
int * | toIntP () const |
Returns the pointer to the data stored as int, or NULL if no data is stored or if the data type is wrong. More... | |
unsigned int * | toUIntP () const |
Returns the pointer to the data stored as unsigned int, or NULL if no data is stored or if the data type is wrong. More... | |
short int * | toShortP () const |
Returns the pointer to the data stored as short int, or NULL if no data is stored or if the data type is wrong. More... | |
unsigned short * | toUShortP () const |
Returns the pointer to the data stored as unsigned short int, or NULL if no data is stored or if the data type is wrong. More... | |
unsigned long int * | toULongIntP () const |
Returns the pointer to the data stored as unsigned long int, or NULL if no data is stored or if the data type is wrong. More... | |
unsigned long long * | toULongLongIntP () const |
float * | toFloatP () const |
Returns the pointer to the data stored as float, or NULL if no data is stored or if the data type is wrong. More... | |
bool * | toBoolP () const |
Returns the pointer to the data stored as a boolean, or NULL if no data is stored or if the data type is wrong. More... | |
unsigned char * | toUCharP () const |
char * | toCharP () const |
char ** | to_C_charP () const |
Returns the pointer to the data stored as a char**, or NULL if no data is stored or if the data type is wrong. More... | |
void * | toVoidP () const |
template<typename T > | |
CuMatrix< T > | toMatrix () const |
template<typename T > | |
CuMatrix< T > * | matrix_ptr () const |
template<typename T > | |
bool | to (T &val) const |
convert the current scalar CuVariant into a variable of type T. More... | |
template<typename T > | |
bool | toVector (std::vector< T > &v) const |
convert the current CuVariant into a vector of type T, if possible. More... | |
void | append (const CuVariant &other) |
Append the content of another variant to this variant. More... | |
CuVariant & | toVector () |
Change the storage format to Vector. More... | |
std::string | dataFormatStr (int f) const |
string representation of CuVariant::DataFormat More... | |
std::string | dataTypeStr (int t) const |
string representation of the CuVariant::DataType More... | |
CuVariant class acts like a union for the cumbia data types.
A CuVariant object holds a single value of a single getType type at a time. Some types are multi-valued, for example those with DataFormat::Vector format.
You can find out what type the CuVariant holds, with CuVariant::getType. The types of data supported are listed in the DataType enumeration. The data formats that is possible to store are declared in the DataFormat enum.
For each supported data type and format, appropriate constructors and toXXX() methods are provided to extract the stored value.
Data is implicitly shared, enabling copy on write. Atomic reference counters make the class reentrant, meaning that methods can be called from multiple threads, but only if each invocation uses its own data. Atomic reference counting is used to ensure the integrity of the shared data. Since cumbia 1.4.0, CuData uses implicit sharing as well.
CuVariant is used to store values associated to keys in CuData bundles. CuData is the object used to exchange data inside the cumbia library and between the library and the clients.
The DataFormat enum lists the different data formats supported by CuVariant.
Enumerator | |
---|---|
FormatInvalid | invalid format |
Scalar | a scalar value |
Vector | a vector, or array |
Matrix | a two dimensional vector (matrix) |
EndFormatTypes | upper limit value for format types |
enum CuVariant::DataType |
The DataType enum lists the different data types that can be held by CuVariant.
CuVariant::CuVariant | ( | const size_t | size, |
DataFormat | df, | ||
DataType | dt | ||
) |
|
virtual |
the class destructor
calls cleanup to free all resources used by the object
CuVariant::CuVariant | ( | short int | i | ) |
CuVariant::CuVariant | ( | short unsigned int | u | ) |
CuVariant::CuVariant | ( | int | i | ) |
builds a CuVariant holding the specified integer
i | the value that will be stored by the object as int |
Specific conversion method: CuVariant::toInt
CuVariant::CuVariant | ( | unsigned int | ui | ) |
builds a CuVariant holding the specified unsigned integer
ui | the value that will be stored by the object as unsigned int |
Specific conversion method: CuVariant::toUInt
CuVariant::CuVariant | ( | long int | li | ) |
builds a CuVariant holding the specified long integer
li | the value that will be stored by the object as long int |
Specific conversion method: CuVariant::toLongInt
CuVariant::CuVariant | ( | long long int | li | ) |
CuVariant::CuVariant | ( | unsigned long int | lui | ) |
builds a CuVariant holding the specified unsigned long integer
lui | the value that will be stored by the object as unsigned long int |
Specific conversion method: CuVariant::toULongInt
CuVariant::CuVariant | ( | unsigned long long int | ului | ) |
CuVariant::CuVariant | ( | float | f | ) |
builds a CuVariant holding the specified float
f | the value that will be stored by the object as float |
Specific conversion method: CuVariant::toFloat
CuVariant::CuVariant | ( | double | dou | ) |
builds a CuVariant holding the specified double
dou | the value that will be stored by the object as double |
Specific conversion method: CuVariant::toDouble
CuVariant::CuVariant | ( | long double | ld | ) |
builds a CuVariant holding the specified long double
ld | the value that will be stored by the object as long double |
Specific conversion method: CuVariant::toLongDouble
References ld(), LongDouble, and Scalar.
CuVariant::CuVariant | ( | bool | b | ) |
builds a CuVariant holding the specified boolean value
b | the value that will be stored by the object as bool |
Specific conversion method: CuVariant::toBool
CuVariant::CuVariant | ( | const std::string & | s | ) |
builds a CuVariant holding the specified std::string
s | the value that will be stored by the object as string |
Specific conversion method: CuVariant::toString
CuVariant::CuVariant | ( | const char * | s | ) |
builds a CuVariant holding the specified constant char string
s | the value that will be stored by the object as string |
Specific conversion method: CuVariant::toString
CuVariant::CuVariant | ( | void * | ptr | ) |
CuVariant::CuVariant | ( | const std::vector< unsigned char > & | m, |
size_t | dimx, | ||
size_t | dimy | ||
) |
CuVariant::CuVariant | ( | const std::vector< char > & | m, |
size_t | dimx, | ||
size_t | dimy | ||
) |
CuVariant::CuVariant | ( | const std::vector< short int > & | i, |
size_t | dimx, | ||
size_t | dimy | ||
) |
CuVariant::CuVariant | ( | const std::vector< short unsigned int > & | si, |
size_t | dimx, | ||
size_t | dimy | ||
) |
CuVariant::CuVariant | ( | const std::vector< int > & | vi, |
size_t | dimx, | ||
size_t | dimy | ||
) |
CuVariant::CuVariant | ( | const std::vector< unsigned int > & | ui, |
size_t | dimx, | ||
size_t | dimy | ||
) |
CuVariant::CuVariant | ( | const std::vector< long int > & | li, |
size_t | dimx, | ||
size_t | dimy | ||
) |
CuVariant::CuVariant | ( | const std::vector< long long int > & | lli, |
size_t | dimx, | ||
size_t | dimy | ||
) |
CuVariant::CuVariant | ( | const std::vector< long unsigned int > & | lui, |
size_t | dimx, | ||
size_t | dimy | ||
) |
CuVariant::CuVariant | ( | const std::vector< long long unsigned int > & | llui, |
size_t | dimx, | ||
size_t | dimy | ||
) |
CuVariant::CuVariant | ( | const std::vector< float > & | vf, |
size_t | dimx, | ||
size_t | dimy | ||
) |
CuVariant::CuVariant | ( | const std::vector< double > & | vd, |
size_t | dimx, | ||
size_t | dimy | ||
) |
CuVariant::CuVariant | ( | const std::vector< long double > & | vd, |
size_t | dimx, | ||
size_t | dimy | ||
) |
References LongDouble, and Matrix.
CuVariant::CuVariant | ( | const std::vector< bool > & | vb, |
size_t | dimx, | ||
size_t | dimy | ||
) |
CuVariant::CuVariant | ( | const std::vector< std::string > & | vs, |
size_t | dimx, | ||
size_t | dimy | ||
) |
References Matrix, pretty_pri, and String.
CuVariant::CuVariant | ( | const std::vector< char > & | vc | ) |
CuVariant::CuVariant | ( | const std::vector< unsigned char > & | vc | ) |
CuVariant::CuVariant | ( | const std::vector< short int > & | i | ) |
CuVariant::CuVariant | ( | const std::vector< short unsigned int > & | si | ) |
CuVariant::CuVariant | ( | const std::vector< int > & | vi | ) |
builds a CuVariant holding the specified vector of integers
vi | the value that will be stored by the object as vector of integer elements |
Specific conversion method: CuVariant::toIntVector
CuVariant::CuVariant | ( | const std::vector< unsigned int > & | vi | ) |
builds a CuVariant holding the specified vector of unsigned integers
vi | the value that will be stored by the object as vector of unsigned integer elements |
Specific conversion method: CuVariant::toUIntVector
CuVariant::CuVariant | ( | const std::vector< long int > & | li | ) |
builds a CuVariant holding the specified vector of long integers
li | the value that will be stored by the object as vector of long integer elements |
Specific conversion method: CuVariant::toLongIntVector
CuVariant::CuVariant | ( | const std::vector< long long int > & | lli | ) |
CuVariant::CuVariant | ( | const std::vector< long unsigned int > & | lui | ) |
CuVariant::CuVariant | ( | const std::vector< long long unsigned int > & | llui | ) |
CuVariant::CuVariant | ( | const std::vector< float > & | vf | ) |
builds a CuVariant holding the specified vector of float
li | the value that will be stored by the object as vector of float elements |
Specific conversion method: CuVariant::toFloatVector
CuVariant::CuVariant | ( | const std::vector< double > & | vd | ) |
builds a CuVariant holding the specified vector of double
vd | the value that will be stored by the object as vector of double elements |
Specific conversion method: CuVariant::toDoubleVector
CuVariant::CuVariant | ( | const std::vector< long double > & | vd | ) |
builds a CuVariant holding the specified vector of long double
vd | the value that will be stored by the object as vector of long double elements |
Specific conversion method: CuVariant::toLongDoubleVector
References LongDouble, and Vector.
CuVariant::CuVariant | ( | const std::vector< bool > & | vb | ) |
builds a CuVariant holding the specified vector of booleans
vb | the value that will be stored by the object as vector of bool elements |
Specific conversion method: CuVariant::toBoolVector
CuVariant::CuVariant | ( | const std::vector< std::string > & | vs | ) |
builds a CuVariant holding the specified vector of std::string
vs | the value that will be stored by the object as vector of string elements |
Specific conversion method: CuVariant::toStringVector
CuVariant::CuVariant | ( | const std::vector< void * > & | vptr | ) |
builds a CuVariant holding the specified vector of void* pointers
li | the value that will be stored by the object as vector of void* elements |
Specific conversion method: CuVariant::toFloatVector
CuVariant::CuVariant | ( | const CuVariant & | other | ) |
copy constructor
Create a new variant initialized from the values of the other parameter
other | the CuVariant to copy from. |
CuVariant::CuVariant | ( | CuVariant && | other | ) |
CuVariant::CuVariant | ( | ) |
Creates an empty (invalid) CuVariant.
The CuVariant created is not valid and null.
References FormatInvalid, and TypeInvalid.
Referenced by append().
CuVariant::CuVariant | ( | const T * | p, |
size_t | siz, | ||
DataFormat | f, | ||
DataType | t, | ||
int | rows = 1 |
||
) |
void CuVariant::append | ( | const CuVariant & | other | ) |
Append the content of another variant to this variant.
other | another CuVariant |
The data stored into this variant is converted to a std::vector of the same type using the native toXXXVector method. The other variant value is converted to a std::vector of the type of this variant using CuVariant::toVector<T>.
The vector from the other variant is then appended to the vector from this variant.
References Boolean, Char, CuVariant(), Double, EndDataTypes, Float, getFormat(), Int, LongDouble, LongInt, LongLongInt, LongLongUInt, LongUInt, Matrix, perr, Short, String, toBoolVector(), toCharVector(), toDoubleVector(), toFloatVector(), toIntVector(), toLongDoubleVector(), toLongIntVector(), toLongLongIntVector(), toLongLongUIntVector(), toShortVector(), toStringVector(), toUCharVector(), toUIntVector(), toULongIntVector(), toUShortVector(), toVector(), TypeInvalid, UChar, UInt, UShort, Vector, and VoidPtr.
bool CuVariant::b | ( | ) | const |
References toBool().
Referenced by CuVariant(), and toBool().
|
inline |
References toBoolVector().
Referenced by toVector().
|
inline |
References toCharVector().
double CuVariant::d | ( | ) | const |
References toDouble().
Referenced by CuData::b(), and CuData::d().
std::string CuVariant::dataFormatStr | ( | int | f | ) | const |
string representation of CuVariant::DataFormat
f | a value from the CuVariant::DataFormat enum |
References EndFormatTypes, and f().
Referenced by to(), and toStringVector().
std::string CuVariant::dataTypeStr | ( | int | t | ) | const |
string representation of the CuVariant::DataType
t | a value from CuVariant::DataType |
References EndDataTypes.
Referenced by to(), toString(), and toStringVector().
|
inline |
References toDoubleVector().
float CuVariant::f | ( | ) | const |
References toFloat().
Referenced by CuVariant(), dataFormatStr(), and toFloat().
|
inline |
References toFloatVector().
size_t CuVariant::get_dim_x | ( | ) | const |
Referenced by CuDataSerializer::serialize().
size_t CuVariant::get_dim_y | ( | ) | const |
CuVariant::DataFormat CuVariant::getFormat | ( | ) | const |
get the format of the data stored
Referenced by append(), operator==(), and CuDataSerializer::serialize().
size_t CuVariant::getSize | ( | ) | const |
Returns the size of the data stored by the CuVariant.
Referenced by operator==(), and CuDataSerializer::serialize().
CuVariant::DataType CuVariant::getType | ( | ) | const |
Returns the DataType stored by CuVariant.
Referenced by operator==(), and CuDataSerializer::serialize().
int CuVariant::i | ( | ) | const |
References toInt().
Referenced by CuVariant(), CuData::i(), toInt(), toLongInt(), toLongLongInt(), toString(), toStringVector(), toUInt(), toULongInt(), toULongLongInt(), and toVector().
bool CuVariant::isFloatingPoint | ( | ) | const |
returns true if the stored data is a floating point number
References Double, Float, and LongDouble.
bool CuVariant::isInteger | ( | ) | const |
returns true if the stored data is an integer number
References Char, Int, LongInt, LongLongInt, LongLongUInt, LongUInt, Short, UChar, UInt, and UShort.
bool CuVariant::isNull | ( | ) | const |
bool CuVariant::isSignedType | ( | ) | const |
References Char, Int, LongInt, LongLongInt, and Short.
bool CuVariant::isUnsignedType | ( | ) | const |
References LongLongUInt, LongUInt, UChar, UInt, and UShort.
bool CuVariant::isValid | ( | ) | const |
Returns whether the data stored by CuVariant is valid.
Referenced by operator==().
bool CuVariant::isVoidPtr | ( | ) | const |
returns true if the data stored is a void * pointer
References VoidPtr.
bool CuVariant::isWNull | ( | ) | const |
|
inline |
References toIntVector().
long CuVariant::l | ( | ) | const |
References toLongInt().
long double CuVariant::ld | ( | ) | const |
References toLongDouble().
Referenced by CuVariant(), and toVector().
|
inline |
References toLongDoubleVector().
Referenced by toVector().
long long CuVariant::ll | ( | ) | const |
References toLongLongInt().
|
inline |
References toLongLongIntVector().
|
inline |
References toLongIntVector().
CuMatrix< T > * CuVariant::matrix_ptr |
Referenced by operator==().
bool CuVariant::operator!= | ( | const CuVariant & | other | ) | const |
returns the opposite result of the equality operator
References operator==().
move assignment operator, moves data from another source
other | CuVariant to move from |
bool CuVariant::operator== | ( | const CuVariant & | other | ) | const |
equality relational operator. Returns true if this CuVariant equals another one
other | CuVariant to compare this to |
The method first checks if getFormat, getSize, getType, isNull, isValid return values coincide. Then memcmp is used to compare the value of this and the other CuVariant.
References Boolean, Char, cuprintf, Double, Float, getFormat(), getSize(), getType(), Int, isNull(), isValid(), LongDouble, LongInt, LongLongInt, LongLongUInt, LongUInt, Matrix, matrix_ptr(), Short, String, UChar, UInt, UShort, and VoidPtr.
Referenced by operator!=().
std::string CuVariant::s | ( | ) | const |
References toString().
Referenced by CuVariant(), CuData::s(), to(), toShortInt(), and toUShortInt().
std::string CuVariant::s | ( | const char * | fmt, |
bool * | ok = nullptr |
||
) | const |
References toString().
short CuVariant::si | ( | ) | const |
References toShortInt().
|
inline |
References toShortVector().
std::vector< std::string > CuVariant::sv | ( | ) | const |
References toStringVector().
Referenced by toVector().
std::vector< std::string > CuVariant::sv | ( | const char * | fmt, |
bool * | ok = nullptr |
||
) | const |
References toStringVector().
bool CuVariant::to | ( | T & | val | ) | const |
convert the current scalar CuVariant into a variable of type T.
val | a reference to a variable of type T |
This method tries to convert the value stored into the CuVariant into the desired type passed as reference.
References Boolean, Char, dataFormatStr(), dataTypeStr(), Double, Float, Int, LongDouble, LongInt, LongLongInt, LongLongUInt, LongUInt, perr, pwarn, s(), Scalar, Short, String, toString(), UChar, UInt, UShort, and Vector.
Referenced by CuData::B(), CuData::D(), CuData::I(), and CuData::U().
char ** CuVariant::to_C_charP | ( | ) | const |
Returns the pointer to the data stored as a char**, or NULL if no data is stored or if the data type is wrong.
Combined with getSize allows to get the stored data in a "C" style (as scalar, if size is 1, or array)
References Matrix, and String.
Referenced by CuDataSerializer::serialize().
bool CuVariant::toBool | ( | bool * | ok = nullptr | ) | const |
convert the stored data into a scalar boolean
*ok | a pointer to a bool. If not null, its value will be set to true if the conversion is successful, false otherwise (wrong data type, format, invalid CuVariant or NULL value) |
References b(), Boolean, and Scalar.
Referenced by b(), and toVector().
bool * CuVariant::toBoolP | ( | ) | const |
Returns the pointer to the data stored as a boolean, or NULL if no data is stored or if the data type is wrong.
Combined with getSize allows to get the stored data in a "C" style (as scalar, if size is 1, or array)
References Boolean, and Matrix.
Referenced by CuDataSerializer::serialize().
std::vector< bool > CuVariant::toBoolVector | ( | ) | const |
convert the stored data into a vector of booleans
Compatible constructor: CuVariant::CuVariant(const std::vector<bool> &vb)
Referenced by append(), bv(), and toVector().
char * CuVariant::toCharP | ( | ) | const |
Referenced by CuDataSerializer::serialize().
std::vector< char > CuVariant::toCharVector | ( | ) | const |
convert the stored data into a vector of char
Referenced by append(), cv(), and toVector().
double CuVariant::toDouble | ( | bool * | ok = nullptr | ) | const |
convert the stored data into a double scalar
*ok | a pointer to a bool. If not null, its value will be set to true if the conversion is successful, false otherwise (wrong data type, format, invalid CuVariant or NULL value) |
References Double, and Scalar.
Referenced by d(), and toVector().
double * CuVariant::toDoubleP | ( | ) | const |
Returns the pointer to the data stored as double, or NULL if no data is stored or if the data type is wrong.
Combined with getSize allows to get the stored data in a "C" style (as scalar, if size is 1, or array).
References Double, and Matrix.
Referenced by CuDataSerializer::serialize().
std::vector< double > CuVariant::toDoubleVector | ( | ) | const |
convert the stored data into a vector of double
Compatible constructor: CuVariant::CuVariant(const std::vector<double> &vd)
Referenced by append(), dv(), and toVector().
float CuVariant::toFloat | ( | bool * | ok = nullptr | ) | const |
convert the stored data into a scalar floating point number
*ok | a pointer to a bool. If not null, its value will be set to true if the conversion is successful, false otherwise (wrong data type, format, invalid CuVariant or NULL value) |
References f(), Float, and Scalar.
Referenced by f(), and toVector().
float * CuVariant::toFloatP | ( | ) | const |
Returns the pointer to the data stored as float, or NULL if no data is stored or if the data type is wrong.
Combined with getSize allows to get the stored data in a "C" style (as scalar, if size is 1, or array)
Referenced by CuDataSerializer::serialize().
std::vector< float > CuVariant::toFloatVector | ( | ) | const |
convert the stored data into a vector of float
Compatible constructor: CuVariant::CuVariant(const std::vector<float> &vf)
Referenced by append(), fv(), and toVector().
int CuVariant::toInt | ( | bool * | ok = nullptr | ) | const |
convert the stored data into a scalar integer
*ok | a pointer to a bool. If not null, its value will be set to true if the conversion is successful, false otherwise (wrong data type, format, invalid CuVariant or NULL value) |
References i(), Int, Scalar, and Short.
Referenced by i(), and toVector().
int * CuVariant::toIntP | ( | ) | const |
Returns the pointer to the data stored as int, or NULL if no data is stored or if the data type is wrong.
Combined with getSize allows to get the stored data in a "C" style (as scalar, if size is 1, or array)
Referenced by CuDataSerializer::serialize().
std::vector< int > CuVariant::toIntVector | ( | ) | const |
convert the stored data into a vector of integers
Compatible constructor: CuVariant::CuVariant(const std::vector<int> &vi)
Referenced by append(), iv(), and toVector().
long double CuVariant::toLongDouble | ( | bool * | ok = nullptr | ) | const |
convert the stored data into a long double scalar
*ok | a pointer to a bool. If not null, its value will be set to true if the conversion is successful, false otherwise (wrong data type, format, invalid CuVariant or NULL value) |
References LongDouble, and Scalar.
Referenced by ld(), and toVector().
long double * CuVariant::toLongDoubleP | ( | ) | const |
Returns the pointer to the data stored as long double, or NULL if no data is stored or if the data type is wrong.
Combined with getSize allows to get the stored data in a "C" style (as scalar, if size is 1, or array)
References LongDouble, and Matrix.
Referenced by CuDataSerializer::serialize().
std::vector< long double > CuVariant::toLongDoubleVector | ( | ) | const |
convert the stored data into a vector of long double
Compatible constructor: CuVariant::CuVariant(const std::vector<long double> &vd)
Referenced by append(), ldv(), and toVector().
long int CuVariant::toLongInt | ( | bool * | ok = nullptr | ) | const |
convert the stored data into a scalar long int
*ok | a pointer to a bool. If not null, its value will be set to true if the conversion is successful, false otherwise (wrong data type, format, invalid CuVariant or NULL value) |
References i(), Int, LongInt, and Scalar.
Referenced by l(), and toVector().
long int * CuVariant::toLongIntP | ( | ) | const |
Returns the pointer to the data stored as long int, or NULL if no data is stored or if the data type is wrong.
Combined with getSize allows to get the stored data in a "C" style (as scalar, if size is 1, or array)
References LongInt, and Matrix.
Referenced by CuDataSerializer::serialize().
std::vector< long int > CuVariant::toLongIntVector | ( | ) | const |
convert the stored data into a vector of long integers
Compatible constructor: CuVariant::CuVariant(const std::vector<long> &li)
Referenced by append(), lv(), and toVector().
long long CuVariant::toLongLongInt | ( | bool * | ok = nullptr | ) | const |
long long int * CuVariant::toLongLongIntP | ( | ) | const |
References LongLongInt, and Matrix.
Referenced by CuDataSerializer::serialize().
std::vector< long long > CuVariant::toLongLongIntVector | ( | ) | const |
Referenced by append(), llv(), and toVector().
std::vector< unsigned long long > CuVariant::toLongLongUIntVector | ( | ) | const |
convert the stored data into a vector of unsigned long long integers
Compatible constructor: CuVariant::CuVariant(const std::vector<unsigned long long> &vi)
Referenced by append(), toVector(), and ullv().
short CuVariant::toShortInt | ( | bool * | ok = nullptr | ) | const |
convert the stored data into a scalar signed short
*ok | a pointer to a bool. If not null, its value will be set to true if the conversion is successful, false otherwise (wrong data type, format, invalid CuVariant or NULL value) |
References s(), Scalar, and Short.
Referenced by si(), and toVector().
short * CuVariant::toShortP | ( | ) | const |
Returns the pointer to the data stored as short int, or NULL if no data is stored or if the data type is wrong.
Combined with getSize allows to get the stored data in a "C" style (as scalar, if size is 1, or array)
Referenced by CuDataSerializer::serialize().
std::vector< short > CuVariant::toShortVector | ( | ) | const |
convert the stored data into a vector of short integers
Compatible constructor: CuVariant::CuVariant(const std::vector<short> &si)
Referenced by append(), siv(), and toVector().
std::string CuVariant::toString | ( | bool * | ok = nullptr , |
const char * | format = "" |
||
) | const |
Convert the stored value to a string representation.
This method converts the data stored by CuVariant into a string, using the snprintf function with the given format or a default format specifier chosen on the basis of the data type.
The conversion specifier can be given through the format parameter of this method
ok | if not null, store in ok the result of the conversion. |
format | a const char specifying the desired format to pass to snprintf |
References Boolean, Char, cuprintf, dataTypeStr(), Double, Float, i(), Int, LongDouble, LongInt, LongLongInt, LongLongUInt, LongUInt, Matrix, perr, CuMatrix< T >::repr(), Scalar, Short, String, UChar, UInt, UShort, Vector, and VoidPtr.
Referenced by s(), to(), toStringVector(), and toVector().
std::vector< std::string > CuVariant::toStringVector | ( | bool * | ok = nullptr | ) | const |
References toStringVector().
Referenced by append(), sv(), toStringVector(), and toVector().
std::vector< std::string > CuVariant::toStringVector | ( | const char * | fmt | ) | const |
References toStringVector().
std::vector< std::string > CuVariant::toStringVector | ( | const char * | fmt, |
bool * | ok | ||
) | const |
convert the stored data into a vector of strings
*ok | a pointer to a bool. If not null, its value will be set to true if the conversion is successful, false otherwise (wrong data type, format, invalid CuVariant or NULL value) |
References Boolean, Char, dataFormatStr(), dataTypeStr(), Double, Float, i(), Int, LongDouble, LongInt, LongUInt, perr, Scalar, Short, String, toString(), UChar, UInt, UShort, and Vector.
unsigned char * CuVariant::toUCharP | ( | ) | const |
Referenced by CuDataSerializer::serialize().
std::vector< unsigned char > CuVariant::toUCharVector | ( | ) | const |
convert the stored data into a vector of unsigned char
Referenced by append(), toVector(), and ucv().
unsigned int CuVariant::toUInt | ( | bool * | ok = nullptr | ) | const |
convert the stored data into a scalar unsigned integer
*ok | a pointer to a bool. If not null, its value will be set to true if the conversion is successful, false otherwise (wrong data type, format, invalid CuVariant or NULL value) |
References i(), Scalar, UInt, and UShort.
Referenced by toVector(), and u().
unsigned int * CuVariant::toUIntP | ( | ) | const |
Returns the pointer to the data stored as unsigned int, or NULL if no data is stored or if the data type is wrong.
Combined with getSize allows to get the stored data in a "C" style (as scalar, if size is 1, or array)
Referenced by CuDataSerializer::serialize().
std::vector< unsigned int > CuVariant::toUIntVector | ( | ) | const |
convert the stored data into a vector of unsigned integers
Compatible constructor: CuVariant::CuVariant(const std::vector<unsigned int> &vi)
Referenced by append(), toVector(), and uv().
unsigned long int CuVariant::toULongInt | ( | bool * | ok = nullptr | ) | const |
convert the stored data into a scalar unsigned long number
*ok | a pointer to a bool. If not null, its value will be set to true if the conversion is successful, false otherwise (wrong data type, format, invalid CuVariant or NULL value) |
References i(), LongUInt, Scalar, and UInt.
Referenced by toVector(), and ul().
unsigned long int * CuVariant::toULongIntP | ( | ) | const |
Returns the pointer to the data stored as unsigned long int, or NULL if no data is stored or if the data type is wrong.
Combined with getSize allows to get the stored data in a "C" style (as scalar, if size is 1, or array)
References LongUInt, and Matrix.
Referenced by CuDataSerializer::serialize().
std::vector< unsigned long int > CuVariant::toULongIntVector | ( | ) | const |
convert the stored data into a vector of unsigned integers
Compatible constructor: CuVariant::CuVariant(const std::vector<unsigned long> &lui)
Referenced by append(), toVector(), and ulv().
unsigned long long int CuVariant::toULongLongInt | ( | bool * | ok | ) | const |
unsigned long long * CuVariant::toULongLongIntP | ( | ) | const |
References LongLongUInt, and Matrix.
Referenced by CuDataSerializer::serialize().
unsigned short CuVariant::toUShortInt | ( | bool * | ok = nullptr | ) | const |
convert the stored data into a scalar unsigned short
*ok | a pointer to a bool. If not null, its value will be set to true if the conversion is successful, false otherwise (wrong data type, format, invalid CuVariant or NULL value) |
References s(), Scalar, and UShort.
Referenced by toVector(), and us().
unsigned short * CuVariant::toUShortP | ( | ) | const |
Returns the pointer to the data stored as unsigned short int, or NULL if no data is stored or if the data type is wrong.
Combined with getSize allows to get the stored data in a "C" style (as scalar, if size is 1, or array)
References Matrix, and UShort.
Referenced by CuDataSerializer::serialize().
std::vector< unsigned short > CuVariant::toUShortVector | ( | ) | const |
convert the stored data into a vector of unsigned short integers
Compatible constructor: CuVariant::CuVariant(const std::vector<unsigned short> &si)
Referenced by append(), toVector(), and usv().
CuVariant & CuVariant::toVector | ( | ) |
Change the storage format to Vector.
modify the CuVariant::DataFormat to vector, so that data can be interpreted as vector
References Vector.
bool CuVariant::toVector | ( | std::vector< T > & | v | ) | const |
convert the current CuVariant into a vector of type T, if possible.
val | a reference to a std vector of type T |
This method tries to convert the value stored into the CuVariant into the desired vector of type T passed as reference.
References Boolean, bv(), Char, Double, Float, i(), Int, ld(), ldv(), LongDouble, LongInt, LongLongInt, LongLongUInt, LongUInt, pwarn, Scalar, Short, String, sv(), toBool(), toBoolVector(), toCharVector(), toDouble(), toDoubleVector(), toFloat(), toFloatVector(), toInt(), toIntVector(), toLongDouble(), toLongDoubleVector(), toLongInt(), toLongIntVector(), toLongLongIntVector(), toLongLongUIntVector(), toShortInt(), toShortVector(), toString(), toStringVector(), toUCharVector(), toUInt(), toUIntVector(), toULongInt(), toULongIntVector(), toUShortInt(), toUShortVector(), UChar, UInt, UShort, and Vector.
Referenced by append(), CuData::BV(), CuData::DV(), CuData::IV(), CuData::LLV(), CuData::ULLV(), CuData::ULV(), and CuData::UV().
void * CuVariant::toVoidP | ( | ) | const |
References VoidPtr.
unsigned int CuVariant::u | ( | ) | const |
References toUInt().
Referenced by CuData::u().
|
inline |
References toUCharVector().
unsigned long CuVariant::ul | ( | ) | const |
References toULongInt().
unsigned long long CuVariant::ull | ( | ) | const |
References toULongLongInt().
|
inline |
References toLongLongUIntVector().
|
inline |
References toULongIntVector().
unsigned short CuVariant::us | ( | ) | const |
References toUShortInt().
|
inline |
References toUShortVector().
|
inline |
References toUIntVector().