This class can be used to store integer or float data with a dynamical binding.
More...
|
| | Variant ()=default |
| | The class default constructor.
|
| | Variant (Type type, void *pData, size_t numItems) |
| | The class constructor with type information and data.
|
| | Variant (bool value) |
| | The class constructor with a boolean value.
|
| | Variant (const Variant &other) |
| | The class copy constructor.
|
| | ~Variant () |
| | The class destructor.
|
| Type | getType () const |
| | Returns the type of the instance.
|
| size_t | getSize () const |
| | Will return the size in bytes of the stored type.
|
| void * | getPtr () const |
| | Will return a raw pointer showing to the data.
|
| void | setByte (uint8_t value) |
| | Will set the payload to the given value.
|
| uint8_t | getByte () const |
| | Will return the current payload as a byte value.
|
| void | setInt (int32_t val) |
| | Sets a new integer value, old values will be released and destroyed.
|
| int32_t | getInt () const |
| | Returns the integer value of the instance.
|
| void | setInt3 (int32_t val1, int32_t val2, int32_t val3) |
| | Set a new integer vector, the old data will be released and destroyed.
|
| int32_t * | getInt3 () const |
| | Returns a pointer to the first element of the integer vector.
|
| void | setInt4 (int32_t val1, int32_t val2, int32_t val3, int32_t val4) |
| | Set a new integer vector, the old data will be released and destroyed.
|
| int32_t * | getInt4 () const |
| | Returns a pointer to the first element of the integer vector.
|
| void | setFloat (float val) |
| | Returns the float value of the instance.
|
| float | getFloat () const |
| | Returns the float value of the instance.
|
| void | setFloat3 (float val1, float val2, float val3) |
| | Set a new float vector, the old data will be released and destroyed.
|
| float * | getFloat3 () const |
| | Returns a pointer to the first element of the float vector.
|
| void | setFloat4 (float val1, float val2, float val3, float val4) |
| | Set a new float vector, the old data will be released and destroyed.
|
| float * | getFloat4 () const |
| | Returns a pointer to the first element of the float vector.
|
| void | setFloat4x4 (float *pData) |
| | Assigns a new float 4x4 item.
|
| float * | getFloat4x4 () const |
| | Returns the pointer to the float 4x4 value.
|
| void | setStdString (const std::string &value) |
| | Sets a string value.
|
| const char * | getString () const |
| | Returns a constant reference to the string value.
|
| void | setBool (bool value) |
| | Will set a new bool value.
|
| bool | getBool () const |
| | Will return the bool value.
|
| void | clear () |
| | Clears the variant data, type will set back to None.
|
| bool | operator== (const Variant &rOther) const |
| | Operator implementations.
|
| Variant & | operator= (const Variant &rOther) |
This class can be used to store integer or float data with a dynamical binding.
It stores the type information at the runtime instead of checking this to compile-time. So it is possible to pass integer or float arguments dynamically to arbitrary customers without changing the calling signature of the used interface. If you are trying to get a float value even if the instance stores currently an integer value on a debug build an assertion will be thrown. On a release build it is possible to get values, but an error will be logged.
Definition at line 46 of file Variant.h.
| cppcore::Variant::Variant |
( |
Type | type, |
|
|
void * | pData, |
|
|
size_t | numItems ) |
|
inline |
The class constructor with type information and data.
A data buffer will be used to pass the data. The size of the buffer will be check on runtime as well.
- Parameters
-
| type | Type enumeration. |
| pData | Pointer to the data buffer. |
| numItems | Size of the data buffer. |
Definition at line 222 of file Variant.h.
References isValid(), reserve(), setStdString(), and String.
| void cppcore::Variant::reserve |
( |
Type | type, |
|
|
size_t | size ) |
|
inlineprotected |
Will reserve a buffer for the requested types.
- Parameters
-
| type | The requested type. |
| size | The number of items. |
Definition at line 493 of file Variant.h.
References Boolean, Byte, Float, Float3, Float4, Float4x4, Int, Int3, and Int4.
Referenced by operator=(), setBool(), setByte(), setFloat(), setFloat3(), setFloat4(), setFloat4x4(), setInt(), setInt3(), setInt4(), Variant(), Variant(), and Variant().