A container class for common data types.
This class is used to hold primitive or class types while providing type information. Functions are also provided to convert between types. The following types are supported:
#include <animation/YiVariant.h>
Public Types | |
| enum | TYPE { TYPE_INVALID, TYPE_FLOAT, TYPE_FLOAT_ARRAY, TYPE_FLOAT_VECTOR, TYPE_INT, TYPE_INT_ARRAY, TYPE_QUATERNION, TYPE_STRING } |
Public Member Functions | |
| CYIVariant () | |
| CYIVariant (const CYIVariant &rOther) | |
| ~CYIVariant () | |
| CYIVariant (float fValue) | |
| CYIVariant (const float pfValue[], uint32_t uCount) | |
| CYIVariant (const glm::vec3 &rvValue) | |
| CYIVariant (float fX, float fY, float fZ) | |
| CYIVariant (int32_t nValue) | |
| CYIVariant (const int32_t pnValue[], uint32_t uCount) | |
| CYIVariant (const glm::quat &rValue) | |
| CYIVariant (const CYIString &rsValue) | |
| void | Set (float fValue) |
| void | Set (const float pfValue[], uint32_t uCount) |
| void | Set (const glm::vec3 &rvValue) |
| void | Set (float fX, float fY, float fZ) |
| void | Set (int32_t nValue) |
| void | Set (const int32_t pnValue[], uint32_t uCount) |
| void | Set (const glm::quat &rValue) |
| void | Set (const CYIString &rsValue) |
| void | SetInvalid () |
| float | GetAsFloat () const |
| const float * | GetAsFloatPointer (size_t *pSize=nullptr) const |
| glm::vec3 | GetAsFloatVector () const |
| int32_t | GetAsInt () const |
| const int32_t * | GetAsIntPointer (size_t *pSize=nullptr) const |
| glm::quat | GetAsQuaternion () const |
| CYIString | GetAsString () const |
| bool | IsValid () const |
| TYPE | GetType () const |
| bool | operator+= (const CYIVariant &rOther) |
| Supported types: Int, String, Float and FloatVector. More... | |
| bool | operator-= (const CYIVariant &rOther) |
| Supported types: Int, Float and FloatVector. More... | |
| bool | operator*= (const CYIVariant &rOther) |
| Supported types: Int, Float and FloatVector. More... | |
| bool | operator/= (const CYIVariant &rOther) |
| Supported types: Int, Float and FloatVector. More... | |
| CYIVariant | operator+ (const CYIVariant &rOther) const |
| Supported types: Int, String, Float and FloatVector. More... | |
| CYIVariant | operator- (const CYIVariant &rOther) const |
| Supported types: Int, Float and FloatVector. More... | |
| CYIVariant | operator* (const CYIVariant &rOther) const |
| Supported types: Int, Float and FloatVector. More... | |
| CYIVariant | operator/ (const CYIVariant &rOther) const |
| Supported types: Int, Float and FloatVector. More... | |
| CYIVariant | LogOf () const |
| CYIVariant | ExpOf () const |
| int32_t | GetApproximateSize () const |
Static Public Member Functions | |
| static void | Lerp (const CYIVariant &start, const CYIVariant &end, float *pfPercentages, uint32_t uPercentageCount, CYIVariant &out_variant) |
Friends | |
| bool | operator== (const CYIVariant &rLHS, const CYIVariant &rRHS) |
| Supported types: Int, String, Float, FloatVector and Quaternion. More... | |
| bool | operator!= (const CYIVariant &rLHS, const CYIVariant &rRHS) |
| Supported types: Int, String, Float, FloatVector and Quaternion. More... | |
| enum CYIVariant::TYPE |
The type of data contained in this variant. By default, empty variant objects have a type of Invalid.
|
inline |
Creates an empty variant. The type of the variant is set to Invalid.
|
inline |
|
inline |
| CYIVariant::CYIVariant | ( | float | fValue | ) |
Creates a variant from the floating-point value fValue. The type of the variant is set to Float.
| CYIVariant::CYIVariant | ( | const float | pfValue[], |
| uint32_t | uCount | ||
| ) |
Creates a variant from the floating-point values contained in pfValue, copying exactly uCount values. The type of the variant is set to FloatArray.
| CYIVariant::CYIVariant | ( | const glm::vec3 & | rvValue | ) |
Creates a variant from the floating-point vector rvValue. The type of the variant is set to FloatVector.
| CYIVariant::CYIVariant | ( | float | fX, |
| float | fY, | ||
| float | fZ | ||
| ) |
Creates a variant from the floating-point values fX, fY and fZ. The type of the variant is set to FloatVector.
| CYIVariant::CYIVariant | ( | int32_t | nValue | ) |
Creates a variant from the integer value nValue. The type of the variant is set to Int.
| CYIVariant::CYIVariant | ( | const int32_t | pnValue[], |
| uint32_t | uCount | ||
| ) |
Creates a variant from the integer values contained in pnValue, copying exactly uCount values. The type of the variant is set to IntArray.
| CYIVariant::CYIVariant | ( | const glm::quat & | rValue | ) |
Creates a variant from the quaternion rValue. The type of the variant is set to Quaternion.
| CYIVariant::CYIVariant | ( | const CYIString & | rsValue | ) |
Creates a variant from the String rsValue. The type of the variant is set to String.
| CYIVariant CYIVariant::ExpOf | ( | ) | const |
Calculates and returns the exponential of each value contained in this variant. Does not support Invalid, IntArray, FloatArray, Quaternion and String types.
| int32_t CYIVariant::GetApproximateSize | ( | ) | const |
Returns the approximate size used by this object in memory. Includes both stack and heap memory.
| float CYIVariant::GetAsFloat | ( | ) | const |
Returns the content of this variant as a floating-point value. For array and vector types, the first value is used. Does not support the Invalid type.
| const float* CYIVariant::GetAsFloatPointer | ( | size_t * | pSize = nullptr | ) | const |
Returns the content of this variant as a floating-point array. The number of elements in the array can optionally be returned by providing a pointer to pSize. This variant object retains ownership of the returned array. Does not support the Invalid, Int, IntArray and String types.
| glm::vec3 CYIVariant::GetAsFloatVector | ( | ) | const |
Returns the content of this variant as a floating-point vector. For Float and Int types, the second and third element of the returned vector will be 0. For Quaternion types, the returned value is a vector containing radian euler angles. For array types, the returned value is filled with up to the first 3 items from the array. Does not support the Invalid and String types.
| int32_t CYIVariant::GetAsInt | ( | ) | const |
Returns the content of this variant as an integer value. For array and vector types, the first value is used. Does not support the Invalid type.
| const int32_t* CYIVariant::GetAsIntPointer | ( | size_t * | pSize = nullptr | ) | const |
Returns the content of this variant as an integer array. The number of elements in the array can optionally be returned by providing a pointer to pSize. This variant object retains ownership of the returned array. Does not support the Invalid, Float, FloatVector, FloatArray, Quaternion and String types.
| glm::quat CYIVariant::GetAsQuaternion | ( | ) | const |
Returns the content of this variant as a quaternion. For Int and Float types, only the w component of the quaternion is filled. For FloatVector types, the value is interpreted as euler angles. For array types, the required value is filled with up to the first 4 items from the array. Does not support Invalid and String types.
| CYIString CYIVariant::GetAsString | ( | ) | const |
Returns the content of this variant as a String. Does not support Invalid, FloatArray, FloatVector, IntArray and Quaternion types.
| TYPE CYIVariant::GetType | ( | ) | const |
Returns the type of value contained in this variant.
| bool CYIVariant::IsValid | ( | ) | const |
Returns true if this variant contains a value. That is, this function returns false only if the type of this variant is Invalid.
|
static |
Performs a linear interpolation between two variant objects start and end. The output of the interpolation is stored in out_variant.
The pfPercentages array must contain at least one percentage value (which ranges from 0.0 to 1.0) to specify the point on the interpolation curve to return a value for. For array and vector types, multiple percentage values can be provided and the uPercentageCount parameter must contain the number of available percentage values.
| CYIVariant CYIVariant::LogOf | ( | ) | const |
Calculates and returns the natural logarithm of each value contained in this variant. Does not support Invalid, IntArray, FloatArray, Quaternion and String types.
| CYIVariant CYIVariant::operator* | ( | const CYIVariant & | rOther | ) | const |
Supported types: Int, Float and FloatVector.
| bool CYIVariant::operator*= | ( | const CYIVariant & | rOther | ) |
Supported types: Int, Float and FloatVector.
| CYIVariant CYIVariant::operator+ | ( | const CYIVariant & | rOther | ) | const |
Supported types: Int, String, Float and FloatVector.
| bool CYIVariant::operator+= | ( | const CYIVariant & | rOther | ) |
Supported types: Int, String, Float and FloatVector.
| CYIVariant CYIVariant::operator- | ( | const CYIVariant & | rOther | ) | const |
Supported types: Int, Float and FloatVector.
| bool CYIVariant::operator-= | ( | const CYIVariant & | rOther | ) |
Supported types: Int, Float and FloatVector.
| CYIVariant CYIVariant::operator/ | ( | const CYIVariant & | rOther | ) | const |
Supported types: Int, Float and FloatVector.
| bool CYIVariant::operator/= | ( | const CYIVariant & | rOther | ) |
Supported types: Int, Float and FloatVector.
| void CYIVariant::Set | ( | float | fValue | ) |
Sets the data contained in the variant to the floating-point value fValue. The type of the variant is set to Float.
| void CYIVariant::Set | ( | const float | pfValue[], |
| uint32_t | uCount | ||
| ) |
Sets the data contained in the variant to the floating-point values contained in pfValue, copying exactly uCount values. The type of the variant is set to FloatArray.
| void CYIVariant::Set | ( | const glm::vec3 & | rvValue | ) |
Sets the data contained in the variant to the floating-point vector rvValue. The type of the variant is set to FloatVector.
| void CYIVariant::Set | ( | float | fX, |
| float | fY, | ||
| float | fZ | ||
| ) |
Sets the data contained in the variant to the floating-point values fX, fY and fZ. The type of the variant is set to FloatVector.
| void CYIVariant::Set | ( | int32_t | nValue | ) |
Sets the data contained in the variant to the integer value nValue. The type of the variant is set to Int.
| void CYIVariant::Set | ( | const int32_t | pnValue[], |
| uint32_t | uCount | ||
| ) |
Sets the data contained in the variant to the integer values contained in pnValue, copying exactly uCount values. The type of the variant is set to IntArray.
| void CYIVariant::Set | ( | const glm::quat & | rValue | ) |
Sets the data contained in the variant to the quaternion rValue. The type of the variant is set to Quaternion.
| void CYIVariant::Set | ( | const CYIString & | rsValue | ) |
Sets the data contained in the variant to the string rsValue. The type of the variant is set to String.
| void CYIVariant::SetInvalid | ( | ) |
Clears the data contained in this variant. The type of the variant is set to Invalid.
|
friend |
Supported types: Int, String, Float, FloatVector and Quaternion.
|
friend |
Supported types: Int, String, Float, FloatVector and Quaternion.