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 , EndVariantTypes , 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 | |
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 | |
CuVariant (unsigned int ui) | |
builds a CuVariant holding the specified unsigned integer | |
CuVariant (long int li) | |
builds a CuVariant holding the specified long integer | |
CuVariant (long long int li) | |
CuVariant (unsigned long int lui) | |
builds a CuVariant holding the specified unsigned long integer | |
CuVariant (unsigned long long int ului) | |
CuVariant (float d) | |
builds a CuVariant holding the specified float | |
CuVariant (double d) | |
builds a CuVariant holding the specified double | |
CuVariant (long double ld) | |
builds a CuVariant holding the specified long double | |
CuVariant (bool b) | |
builds a CuVariant holding the specified boolean value | |
CuVariant (const std::string &s) | |
builds a CuVariant holding the specified std::string | |
CuVariant (const char *s) | |
builds a CuVariant from a plain C string | |
CuVariant (void *ptr) | |
builds a CuVariant storing the void * pointer passed as argument | |
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 | |
CuVariant (const std::vector< unsigned char > &uc) | |
vector of unsigned char flavor | |
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 | |
CuVariant (const std::vector< unsigned int > &ui) | |
builds a CuVariant holding the specified vector of unsigned integers | |
CuVariant (const std::vector< long int > &li) | |
builds a CuVariant holding the specified vector of long integers | |
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 | |
CuVariant (const std::vector< double > &vd) | |
builds a CuVariant holding the specified vector of double | |
CuVariant (const std::vector< long double > &vd) | |
builds a CuVariant holding the specified vector of long double | |
CuVariant (const std::vector< bool > &vd) | |
builds a CuVariant holding the specified vector of booleans | |
CuVariant (const std::vector< std::string > &vd) | |
builds a CuVariant holding the specified vector of std::string | |
CuVariant (const std::vector< void * > &vptr) | |
builds a CuVariant holding the specified vector of void* pointers | |
CuVariant (const CuVariant &other) | |
copy constructor | |
CuVariant (CuVariant &&other) | |
move constructor | |
CuVariant () | |
Creates an empty (invalid) CuVariant. | |
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 | |
CuVariant & | operator= (CuVariant &&other) |
move assignment operator, moves data from another source | |
bool | operator== (const CuVariant &other) const |
equality relational operator. Returns true if this CuVariant equals another one | |
bool | operator!= (const CuVariant &other) const |
returns the opposite result of the equality operator | |
DataFormat | getFormat () const |
get the format of the data stored | |
DataType | getType () const |
Returns the DataType stored by CuVariant. | |
size_t | getSize () const |
Returns the size of the data stored by the CuVariant. | |
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 | |
bool | isUnsignedType () const |
bool | isSignedType () const |
bool | isFloatingPoint () const |
returns true if the stored data is a floating point number | |
bool | isVoidPtr () const |
returns true if the data stored is a void * pointer | |
bool | isValid () const |
Returns whether the data stored by CuVariant is valid. | |
bool | isNull () const |
Returns whether the the data stored by CuVariant is nullptr or not. | |
bool | isWNull () const |
std::vector< double > | toDoubleVector () const |
convert the stored data into a vector of double | |
std::vector< double > | dv () const |
std::vector< long double > | toLongDoubleVector () const |
convert the stored data into a vector of long double | |
std::vector< long double > | ldv () const |
std::vector< float > | toFloatVector () const |
convert the stored data into a vector of float | |
std::vector< float > | fv () const |
std::vector< int > | toIntVector () const |
convert the stored data into a vector of integers | |
std::vector< int > | iv () const |
std::vector< unsigned int > | toUIntVector () const |
convert the stored data into a vector of unsigned integers | |
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 | |
std::vector< unsigned long long int > | ullv () const |
std::vector< long int > | toLongIntVector () const |
convert the stored data into a vector of long integers | |
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 | |
std::vector< unsigned long int > | ulv () const |
std::vector< bool > | toBoolVector () const |
convert the stored data into a vector of booleans | |
std::vector< bool > | bv () const |
std::vector< short > | toShortVector () const |
convert the stored data into a vector of short integers | |
std::vector< short > | siv () const |
std::vector< unsigned short > | toUShortVector () const |
convert the stored data into a vector of unsigned short integers | |
std::vector< unsigned short > | usv () const |
std::vector< char > | toCharVector () const |
convert the stored data into a vector of char | |
std::vector< char > | cv () const |
std::vector< unsigned char > | toUCharVector () const |
convert the stored data into a vector of unsigned char | |
std::vector< unsigned char > | ucv () const |
double | toDouble (bool *ok=nullptr) const |
convert the stored data into a double scalar | |
double | d () const |
long double | toLongDouble (bool *ok=nullptr) const |
convert the stored data into a long double scalar | |
long double | ld () const |
unsigned long int | toULongInt (bool *ok=nullptr) const |
convert the stored data into a scalar unsigned long number | |
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 | |
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 | |
int | i () const |
unsigned int | toUInt (bool *ok=nullptr) const |
convert the stored data into a scalar unsigned integer | |
unsigned int | u () const |
unsigned short | toUShortInt (bool *ok=nullptr) const |
convert the stored data into a scalar unsigned short | |
unsigned short | us () const |
short | toShortInt (bool *ok=nullptr) const |
convert the stored data into a scalar signed short | |
short | si () const |
float | toFloat (bool *ok=nullptr) const |
convert the stored data into a scalar floating point number | |
float | f () const |
bool | toBool (bool *ok=nullptr) const |
convert the stored data into a scalar boolean | |
bool | b () const |
std::string | toString (bool *ok=nullptr, const char *format="") const |
Convert the stored value to a string representation. | |
std::string | s () const |
std::string | s (const char *fmt, bool *ok=nullptr) const |
const char * | c_str () 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 | |
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 nullptr if no data is stored or if the data type is wrong. | |
long double * | toLongDoubleP () const |
Returns the pointer to the data stored as long double, or nullptr if no data is stored or if the data type is wrong. | |
long int * | toLongIntP () const |
Returns the pointer to the data stored as long int, or nullptr if no data is stored or if the data type is wrong. | |
long long int * | toLongLongIntP () const |
int * | toIntP () const |
Returns the pointer to the data stored as int, or nullptr if no data is stored or if the data type is wrong. | |
unsigned int * | toUIntP () const |
Returns the pointer to the data stored as unsigned int, or nullptr if no data is stored or if the data type is wrong. | |
short int * | toShortP () const |
Returns the pointer to the data stored as short int, or nullptr if no data is stored or if the data type is wrong. | |
unsigned short * | toUShortP () const |
Returns the pointer to the data stored as unsigned short int, or nullptr if no data is stored or if the data type is wrong. | |
unsigned long int * | toULongIntP () const |
Returns the pointer to the data stored as unsigned long int, or nullptr if no data is stored or if the data type is wrong. | |
unsigned long long * | toULongLongIntP () const |
float * | toFloatP () const |
Returns the pointer to the data stored as float, or nullptr if no data is stored or if the data type is wrong. | |
bool * | toBoolP () const |
Returns the pointer to the data stored as a boolean, or nullptr if no data is stored or if the data type is wrong. | |
unsigned char * | toUCharP () const |
char * | toCharP () const |
char ** | to_C_charP () const |
Returns the pointer to the data stored as a char**, or nullptr if no data is stored or if the data type is wrong. | |
void * | toVoidP () const |
void * | data () const |
return data ptr without any type checking | |
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. | |
template<typename T > | |
bool | toVector (std::vector< T > &v) const |
convert the current CuVariant into a vector of type T, if possible. | |
void | append (const CuVariant &other) |
Append the content of another variant to this variant. | |
CuVariant & | toVector () |
Change the storage format to Vector. | |
std::string | dataFormatStr (int f) const |
string representation of CuVariant::DataFormat | |
std::string | dataTypeStr (int t) const |
string representation of the CuVariant::DataType | |
std::string | dataTypeStr () const |
same as int param version, operates on its type | |
std::string | data_type_short_str () const |
abbreviated return string version of dataTypeStr | |
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 from a plain C string
s | a pointer to a null terminated C string |
Specific conversion method: CuVariant::toString or CuVariant::c_str
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
If the other variant is valid, the contents are copied (see note). Otherwise, the variant remains null, no memory is allocated.
other | the CuVariant to copy from. |
CuVariant::CuVariant | ( | CuVariant && | other | ) |
CuVariant::CuVariant | ( | ) |
Creates an empty (invalid) CuVariant.
The CuVariant created is such as:
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, EndVariantTypes, 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 CuData::b(), CuVariant(), toBool(), and toVector().
|
inline |
References toBoolVector().
const char * CuVariant::c_str | ( | ) | const |
Referenced by CuData::c_str(), CuData::c_str(), to(), toStringVector(), and toVector().
|
inline |
References toCharVector().
double CuVariant::d | ( | ) | const |
References toDouble().
Referenced by CuData::b(), CuData::d(), and CuData::d().
void * CuVariant::data | ( | ) | const |
return data ptr without any type checking
Referenced by CuData::operator==().
std::string CuVariant::data_type_short_str | ( | ) | const |
abbreviated return string version of dataTypeStr
t | the data type |
References EndDataTypes.
Referenced by CuData::toString().
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 | ( | ) | const |
same as int param version, operates on its type
References dataTypeStr().
Referenced by dataTypeStr(), to(), toString(), and toStringVector().
std::string CuVariant::dataTypeStr | ( | int | t | ) | const |
string representation of the CuVariant::DataType
t | a value from CuVariant::DataType |
References EndDataTypes.
|
inline |
References toDoubleVector().
float CuVariant::f | ( | ) | const |
References toFloat().
Referenced by CuVariant(), 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
References FormatInvalid.
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.
References TypeInvalid.
Referenced by operator==(), and CuDataSerializer::serialize().
int CuVariant::i | ( | ) | const |
References toInt().
Referenced by CuVariant(), CuVariant(), CuData::i(), 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 CuData::b(), CuData::containsKey(), CuData::has(), CuData::idx_keys(), CuData::isEmpty(), CuData::merge(), operator==(), CuData::size(), and CuData::toString().
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().
long long CuVariant::ll | ( | ) | const |
References toLongLongInt().
|
inline |
References toLongLongIntVector().
|
inline |
References toLongIntVector().
CuMatrix< T > * CuVariant::matrix_ptr | ( | ) | const |
Referenced by operator==(), to_C_charP(), toBoolP(), toCharP(), toDoubleP(), toFloatP(), toIntP(), toLongDoubleP(), toLongIntP(), toLongLongIntP(), toShortP(), toUCharP(), toUIntP(), toULongIntP(), toULongLongIntP(), and toUShortP().
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, 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(), CuVariant(), CuData::has(), CuData::s(), 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, c_str(), Char, dataFormatStr(), dataTypeStr(), Double, Float, Int, LongDouble, LongInt, LongLongInt, LongLongUInt, LongUInt, pwarn, s(), Scalar, Short, String, toString(), UChar, UInt, UShort, and Vector.
Referenced by CuData::B(), CuData::B(), CuData::D(), CuData::D(), CuData::I(), CuData::I(), CuData::U(), and CuData::U().
char ** CuVariant::to_C_charP | ( | ) | const |
Returns the pointer to the data stored as a char**, or nullptr 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, matrix_ptr(), 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 nullptr 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 nullptr 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, Matrix, and matrix_ptr().
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)
char * CuVariant::toCharP | ( | ) | const |
References Char, Matrix, and matrix_ptr().
Referenced by CuDataSerializer::serialize().
std::vector< char > CuVariant::toCharVector | ( | ) | const |
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 nullptr value) |
References Double, and Scalar.
Referenced by d(), and toVector().
double * CuVariant::toDoubleP | ( | ) | const |
Returns the pointer to the data stored as double, or nullptr 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, Matrix, and matrix_ptr().
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)
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 nullptr 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 nullptr 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 Float, Matrix, and matrix_ptr().
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)
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 nullptr 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 nullptr 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 Int, Matrix, and matrix_ptr().
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)
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 nullptr 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 nullptr 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, Matrix, and matrix_ptr().
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)
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 nullptr 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 nullptr 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, Matrix, and matrix_ptr().
Referenced by CuDataSerializer::serialize().
std::vector< long int > CuVariant::toLongIntVector | ( | ) | const |
long long CuVariant::toLongLongInt | ( | bool * | ok = nullptr | ) | const |
long long int * CuVariant::toLongLongIntP | ( | ) | const |
References LongLongInt, Matrix, and matrix_ptr().
Referenced by CuDataSerializer::serialize().
std::vector< long long > CuVariant::toLongLongIntVector | ( | ) | const |
std::vector< unsigned long long > CuVariant::toLongLongUIntVector | ( | ) | const |
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 nullptr 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 nullptr 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, matrix_ptr(), and Short.
Referenced by CuDataSerializer::serialize().
std::vector< short > CuVariant::toShortVector | ( | ) | const |
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(), CuMatrix< T >::repr_str(), Scalar, Short, String, UChar, UInt, UShort, Vector, and VoidPtr.
Referenced by s(), s(), to(), CuData::toString(), toStringVector(), and toVector().
std::vector< std::string > CuVariant::toStringVector | ( | bool * | ok = nullptr | ) | const |
References toStringVector().
Referenced by append(), sv(), sv(), toStringVector(), 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 nullptr value) |
References Boolean, c_str(), 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 |
References Matrix, matrix_ptr(), and UChar.
Referenced by CuDataSerializer::serialize().
std::vector< unsigned char > CuVariant::toUCharVector | ( | ) | const |
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 nullptr 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 nullptr 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, matrix_ptr(), and UInt.
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)
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 nullptr 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 nullptr 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, Matrix, and matrix_ptr().
Referenced by CuDataSerializer::serialize().
std::vector< unsigned long int > CuVariant::toULongIntVector | ( | ) | const |
unsigned long long int CuVariant::toULongLongInt | ( | bool * | ok | ) | const |
unsigned long long * CuVariant::toULongLongIntP | ( | ) | const |
References LongLongUInt, Matrix, and matrix_ptr().
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 nullptr 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 nullptr 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, matrix_ptr(), and UShort.
Referenced by CuDataSerializer::serialize().
std::vector< unsigned short > CuVariant::toUShortVector | ( | ) | const |
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 b(), Boolean, c_str(), Char, Double, Float, i(), Int, ld(), LongDouble, LongInt, LongLongInt, LongLongUInt, LongUInt, pwarn, Scalar, Short, String, sv(), toBool(), toDouble(), toFloat(), toInt(), toLongDouble(), toLongInt(), toShortInt(), toString(), toStringVector(), toUInt(), toULongInt(), toUShortInt(), UChar, UInt, UShort, and Vector.
Referenced by append(), CuData::BV(), CuData::BV(), CuData::DV(), CuData::DV(), CuData::IV(), CuData::IV(), CuData::LLV(), CuData::LLV(), CuData::ULLV(), CuData::ULLV(), CuData::ULV(), CuData::ULV(), CuData::UV(), and CuData::UV().
void * CuVariant::toVoidP | ( | ) | const |
References VoidPtr.
unsigned int CuVariant::u | ( | ) | const |
References toUInt().
Referenced by CuData::u(), and 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().