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 : uint8_t { Type::Invalid, Type::Float, Type::FloatArray, Type::FloatVec2, Type::FloatVec3, Type::Integer, Type::IntegerArray, Type::Quaternion, Type::String } |
Public Member Functions | |
CYIVariant ()=default | |
CYIVariant (float value) | |
CYIVariant (const float pValue[], uint32_t count) | |
CYIVariant (std::vector< float > values) | |
CYIVariant (const glm::vec2 &rvValue) | |
CYIVariant (float x, float y) | |
CYIVariant (const glm::vec3 &rvValue) | |
CYIVariant (float x, float y, float z) | |
CYIVariant (int32_t value) | |
CYIVariant (const int32_t pValue[], uint32_t count) | |
CYIVariant (std::vector< int32_t > values) | |
CYIVariant (const glm::quat &rValue) | |
CYIVariant (const CYIString &rsValue) | |
void | Set (float value) |
void | Set (const float pValue[], uint32_t count) |
void | Set (std::vector< float > values) |
void | Set (const glm::vec2 &rvValue) |
void | Set (float x, float y) |
void | Set (const glm::vec3 &rvValue) |
void | Set (float x, float y, float z) |
void | Set (int32_t value) |
void | Set (const int32_t pValue[], uint32_t count) |
void | Set (std::vector< int32_t > values) |
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::vec2 | GetAsFloatVec2 () const |
glm::vec3 | GetAsFloatVec3 () 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, FloatVec2, FloatVec3, FloatArray and IntArray. More... | |
bool | operator-= (const CYIVariant &rOther) |
Supported types: Int, Float, FloatVec2, FloatVec3, FloatArray and IntArray. More... | |
bool | operator*= (const CYIVariant &rOther) |
Supported types: Int, Float, FloatVec2, FloatVec3, FloatArray and IntArray. More... | |
bool | operator/= (const CYIVariant &rOther) |
Supported types: Int, Float, FloatVec2, FloatVec3, FloatArray and IntArray. More... | |
CYIVariant | operator+ (const CYIVariant &rOther) const |
Supported types: Int, String, Float, FloatVec2, FloatVec3, FloatArray and IntArray. More... | |
CYIVariant | operator- (const CYIVariant &rOther) const |
Supported types: Int, Float, FloatVec2, FloatVec3, FloatArray and IntArray. More... | |
CYIVariant | operator* (const CYIVariant &rOther) const |
Supported types: Int, Float, FloatVec2, FloatVec3, FloatArray and IntArray. More... | |
CYIVariant | operator/ (const CYIVariant &rOther) const |
Supported types: Int, Float, FloatVec2, FloatVec3, FloatArray and IntArray. More... | |
CYIVariant | LogOf () const |
CYIVariant | ExpOf () const |
size_t | GetApproximateSize () const |
Static Public Member Functions | |
static void | Lerp (const CYIVariant &start, const CYIVariant &end, float *pPercentages, size_t percentageCount, CYIVariant &out_variant) |
Friends | |
bool | operator== (const CYIVariant &rLHS, const CYIVariant &rRHS) |
All types are supported. Two 'invalid' variants are considered to be equal. More... | |
bool | operator!= (const CYIVariant &rLHS, const CYIVariant &rRHS) |
All types are supported. Two 'invalid' variants are considered to be equal. More... | |
|
strong |
The type of data contained in this variant. By default, empty variant objects have a type of Invalid.
|
default |
Creates an empty variant. The type of the variant is set to Invalid.
CYIVariant::CYIVariant | ( | float | value | ) |
Creates a variant from the floating-point value value. The type of the variant is set to Float.
CYIVariant::CYIVariant | ( | const float | pValue[], |
uint32_t | count | ||
) |
Creates a variant from the floating-point values contained in pValue, copying exactly count values. The type of the variant is set to FloatArray.
CYIVariant::CYIVariant | ( | std::vector< float > | values | ) |
Creates a variant from the floating-point values contained in values. The type of the variant is set to FloatArray.
CYIVariant::CYIVariant | ( | const glm::vec2 & | rvValue | ) |
Creates a variant from the floating-point vector rvValue. The type of the variant is set to FloatVec2.
CYIVariant::CYIVariant | ( | float | x, |
float | y | ||
) |
Creates a variant from the floating-point values x and y. The type of the variant is set to FloatVec2.
CYIVariant::CYIVariant | ( | const glm::vec3 & | rvValue | ) |
Creates a variant from the floating-point vector rvValue. The type of the variant is set to FloatVec3.
CYIVariant::CYIVariant | ( | float | x, |
float | y, | ||
float | z | ||
) |
Creates a variant from the floating-point values x, y and z. The type of the variant is set to FloatVec3.
CYIVariant::CYIVariant | ( | int32_t | value | ) |
Creates a variant from the integer value value. The type of the variant is set to Int.
CYIVariant::CYIVariant | ( | const int32_t | pValue[], |
uint32_t | count | ||
) |
Creates a variant from the integer values contained in pValue, copying exactly count values. The type of the variant is set to IntArray.
CYIVariant::CYIVariant | ( | std::vector< int32_t > | values | ) |
Creates a variant from the integer values contained in 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.
|
explicit |
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, Quaternion and String types.
size_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::vec2 CYIVariant::GetAsFloatVec2 | ( | ) | const |
Returns the content of this variant as a floating-point vector. For Float and Int types, the second 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 2 items from the array. Does not support the Invalid and String types.
glm::vec3 CYIVariant::GetAsFloatVec3 | ( | ) | 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, FloatVec2, FloatVec3, 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 FloatVec2 and FloatVec3 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, FloatVec2, FloatVec3, 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 pPercentages 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 percentageCount 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, Quaternion and String types.
CYIVariant CYIVariant::operator* | ( | const CYIVariant & | rOther | ) | const |
Supported types: Int, Float, FloatVec2, FloatVec3, FloatArray and IntArray.
bool CYIVariant::operator*= | ( | const CYIVariant & | rOther | ) |
Supported types: Int, Float, FloatVec2, FloatVec3, FloatArray and IntArray.
CYIVariant CYIVariant::operator+ | ( | const CYIVariant & | rOther | ) | const |
Supported types: Int, String, Float, FloatVec2, FloatVec3, FloatArray and IntArray.
bool CYIVariant::operator+= | ( | const CYIVariant & | rOther | ) |
Supported types: Int, String, Float, FloatVec2, FloatVec3, FloatArray and IntArray.
CYIVariant CYIVariant::operator- | ( | const CYIVariant & | rOther | ) | const |
Supported types: Int, Float, FloatVec2, FloatVec3, FloatArray and IntArray.
bool CYIVariant::operator-= | ( | const CYIVariant & | rOther | ) |
Supported types: Int, Float, FloatVec2, FloatVec3, FloatArray and IntArray.
CYIVariant CYIVariant::operator/ | ( | const CYIVariant & | rOther | ) | const |
Supported types: Int, Float, FloatVec2, FloatVec3, FloatArray and IntArray.
bool CYIVariant::operator/= | ( | const CYIVariant & | rOther | ) |
Supported types: Int, Float, FloatVec2, FloatVec3, FloatArray and IntArray.
void CYIVariant::Set | ( | float | value | ) |
Sets the data contained in the variant to the floating-point value value. The type of the variant is set to Float.
void CYIVariant::Set | ( | const float | pValue[], |
uint32_t | count | ||
) |
Sets the data contained in the variant to the floating-point values contained in pValue, copying exactly count values. The type of the variant is set to FloatArray.
void CYIVariant::Set | ( | std::vector< float > | values | ) |
Sets the data contained in the variant to the floating-point values contained in values. The type of the variant is set to FloatArray.
void CYIVariant::Set | ( | const glm::vec2 & | rvValue | ) |
Sets the data contained in the variant to the floating-point vector rvValue. The type of the variant is set to FloatVec2.
void CYIVariant::Set | ( | float | x, |
float | y | ||
) |
Sets the data contained in the variant to the floating-point values x and y. The type of the variant is set to FloatVec2.
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 FloatVec3.
void CYIVariant::Set | ( | float | x, |
float | y, | ||
float | z | ||
) |
Sets the data contained in the variant to the floating-point values x, y and z. The type of the variant is set to FloatVec3.
void CYIVariant::Set | ( | int32_t | value | ) |
Sets the data contained in the variant to the integer value value. The type of the variant is set to Int.
void CYIVariant::Set | ( | const int32_t | pValue[], |
uint32_t | count | ||
) |
Sets the data contained in the variant to the integer values contained in pValue, copying exactly count values. The type of the variant is set to IntArray.
void CYIVariant::Set | ( | std::vector< int32_t > | values | ) |
Sets the data contained in the variant to the integer values contained in 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 |
All types are supported. Two 'invalid' variants are considered to be equal.
|
friend |
All types are supported. Two 'invalid' variants are considered to be equal.