variant.hpp File Reference

Classes

struct  kanzi::Variant
 Union container for manipulating an object from a heterogeneous set of types in a uniform manner. More...
 

Namespaces

 kanzi
 

Functions

KANZI_API kzsError kzuVariantSetEmpty (struct kanzi::Variant *variant)
 Set a variant to be empty. More...
 
KANZI_API kzBool kzuVariantIsEmpty (const struct kanzi::Variant *variant)
 Checks if a variant is empty. More...
 
KANZI_API kanzi::PropertyDataType kzuVariantGetType (const struct kanzi::Variant *variant)
 Get the type of the value stored in a variant. More...
 
KANZI_API kzsError kzuVariantSetFloatWithField (struct kanzi::Variant *variant, kanzi::PropertyField field, float value)
 Set a float field of a variant. More...
 
KANZI_API float kzuVariantGetFloatWithField (const struct kanzi::Variant *variant, kanzi::PropertyField field)
 Get the float value stored in a variant, also use field. More...
 
KANZI_API kzBool kzuVariantIsEqual (const struct kanzi::Variant *variantA, const struct kanzi::Variant *variantB)
 Check if variants are equal. More...
 
KANZI_API kanzi::PropertyDataType kzuVariantResolveType (const struct kanzi::Variant *variant, kanzi::PropertyField field)
 Resolve the actual data type of a variant, including the field. More...
 
KANZI_API kzsError kzuVariantCast (struct kanzi::Variant *targetVariant, kanzi::PropertyDataType targetDataType, const struct kanzi::Variant *sourceVariant, kzBool *out_cast)
 Cast a variant into the target variant. More...
 
KANZI_API kzsError kzuVariantInitializeFromProperty (const kanzi::Object *object, kanzi::AbstractPropertyType propertyType, kanzi::PropertyField field, struct kanzi::Variant *variant, kzBool *out_found)
 Gets an object's property from a property manager and sets the property value to the given variant. More...
 
KANZI_API kzsError kzuVariantSetToProperty (const struct kanzi::Variant *variant, kanzi::Object *object, kanzi::AbstractPropertyType propertyType, kanzi::PropertyField field, kzBool *out_written)
 Sets an object's property from a variant. More...
 
KANZI_API kzsError kzuVariantFilterWithField (struct kanzi::Variant *variant, kanzi::PropertyField field)
 Changes the value and the type of the variant to a sub-value and a sub-type of the variant. More...
 

Function Documentation

KANZI_API kzsError kzuVariantSetEmpty ( struct kanzi::Variant variant)

Set a variant to be empty.

Empty variants are considered invalid.

KANZI_API kzBool kzuVariantIsEmpty ( const struct kanzi::Variant variant)

Checks if a variant is empty.

Empty variants are considered invalid.

KANZI_API kanzi::PropertyDataType kzuVariantGetType ( const struct kanzi::Variant variant)

Get the type of the value stored in a variant.

KANZI_API kzsError kzuVariantSetFloatWithField ( struct kanzi::Variant variant,
kanzi::PropertyField  field,
float  value 
)

Set a float field of a variant.

KANZI_API float kzuVariantGetFloatWithField ( const struct kanzi::Variant variant,
kanzi::PropertyField  field 
)

Get the float value stored in a variant, also use field.

KANZI_API kzBool kzuVariantIsEqual ( const struct kanzi::Variant variantA,
const struct kanzi::Variant variantB 
)

Check if variants are equal.

Empty variants are not equal to each other. KZU_PROPERTY_DATA_TYPE_STRUCT and KZU_PROPERTY_DATA_TYPE_ARRAY data types are not supported.

Returns
KZ_TRUE if the variants are equal, KZ_FALSE otherwise.
KANZI_API kanzi::PropertyDataType kzuVariantResolveType ( const struct kanzi::Variant variant,
kanzi::PropertyField  field 
)

Resolve the actual data type of a variant, including the field.

Parameters
variantVariant to examine.
fieldField.
Returns
Data type.
KANZI_API kzsError kzuVariantCast ( struct kanzi::Variant targetVariant,
kanzi::PropertyDataType  targetDataType,
const struct kanzi::Variant sourceVariant,
kzBool out_cast 
)

Cast a variant into the target variant.

Parameters
targetVariantThe variant which value is written.
targetDataType::KzuPropertyDataType to use as the target variant's data type.
sourceVariantThe variant which value is read.
out_castSet on success. The value is KZ_TRUE if the cast succeeded, otherwise KZ_FALSE.
Returns
KZS_SUCCESS on success.
KANZI_API kzsError kzuVariantInitializeFromProperty ( const kanzi::Object object,
kanzi::AbstractPropertyType  propertyType,
kanzi::PropertyField  field,
struct kanzi::Variant variant,
kzBool out_found 
)

Gets an object's property from a property manager and sets the property value to the given variant.

Parameters
propertyManagerThe property manager to use.
objectObject owning the property to read.
propertyType::KzuPropertyType of the property to read.
fieldThe field to read from the property.
variantPreviously created variant which value is set.
out_foundSet on success. The value is KZ_TRUE if the property was found, otherwise KZ_FALSE.
Returns
KZS_SUCCESS on success, KZS_ERROR_ENUM_OUT_OF_RANGE in case of unsuitable data type or field.
KANZI_API kzsError kzuVariantSetToProperty ( const struct kanzi::Variant variant,
kanzi::Object object,
kanzi::AbstractPropertyType  propertyType,
kanzi::PropertyField  field,
kzBool out_written 
)

Sets an object's property from a variant.

Parameters
variantVariant which value is read.
propertyManagerThe property manager to use.
objectObject owning the property to set.
propertyType::KzuPropertyType of the property to set.
field::KzuPropertyField of the property to set.
out_foundSet on success. The value is KZ_TRUE if the property was written, otherwise KZ_FALSE.
Returns
KZS_SUCCESS on success, KZU_ERROR_WRONG_PROPERTY_DATA_TYPE if the field is not suitable, KZS_ERROR_ENUM_OUT_OF_RANGE if the variant data type is invalid.
KANZI_API kzsError kzuVariantFilterWithField ( struct kanzi::Variant variant,
kanzi::PropertyField  field 
)

Changes the value and the type of the variant to a sub-value and a sub-type of the variant.

Parameters
variantVariant which value is filtered.
fieldThe field to filter by.
Returns
KZS_SUCCESS on success, KZU_ERROR_WRONG_PROPERTY_DATA_TYPE if the field is not suitable for filtering, KZS_ERROR_ENUM_OUT_OF_RANGE if the variant data type is invalid.