A schema variant is an object used by schema that can hold a single piece of data that can be reassigned with a new value (And possibly type).
The supported types are:
Type | Description | Function to set |
---|---|---|
bool | A standard C++ boolean type with true and false values | SchemaVariantSetBool |
double | A double precision floating point | SchemaVariantSetNumber |
LPCWSTR | A Unicode string | SchemaVariantSetString |
void * | Any arbitrary data | SchemaVariantSetPointer |
To create a schema variant you call SchemaVariantCreate followed by a call to set some data into it with the appropriate function. Until you have set data into the newly created schema variant the type of the schema variant will be SystemType::Undefined. Calling schema variant functions on undefined schema variants may fail.
When you are finished with a schema variant call SchemaVariantDelete to free the schema variant.
void MakeVariant() { SchemaVariantHandle variant = SchemaVariantCreate(); // Type is SystemType::Undefined SchemaVariantSetNumber(variant, 123.45f); // Type is now SystemType::Number, value 123.45 SchemaVariantDelete(variant); // Remember to delete the variant when finished } |
You can set/change the value and type of a schema variant with the following calls
Function | Description | Resulting type |
---|---|---|
SchemaVariantSetBool | Sets the schema variant to a boolean value | SystemType::Boolean |
SchemaVariantSetNumber | Sets the schema variant to a double value | SystemType::ANumber |
SchemaVariantSetString | Sets the schema variant to a string value | SystemType::AString |
SchemaVariantSetPointer | Sets the schema variant to a pointer | The user defined type |
SchemaVariantSet | Sets a schema variant from another schema variant | Same as source schema variant |
void ChangeVariant() { SchemaVariantHandle variant = SchemaVariantCreate(); // Type is SystemType::Undefined SchemaVariantSetNumber(variant, 123.45f); // Type is now SystemType::Number, value 123.45 SchemaVariantSetString(variant, L"Hello World"); // Type is now SystemType::AString SchemaVariantDelete(variant); // Remember to delete the variant when finished } |
Table of Contents