CFx SDK Documentation
2020SP3
|
#include <GiVariant.h>
Classes | |
class | EnumType |
Public Types | |
enum | VariantType { kUndefined = 0, kBoolean, kInt, kDouble, kColor, kString, kTable } |
Static Public Member Functions | |
static OdSmartPtr< OdGiVariant > | createObject (const OdGiVariant &value) |
static OdSmartPtr< OdGiVariant > | createObject (bool value) |
static OdSmartPtr< OdGiVariant > | createObject (OdInt32 value) |
static OdSmartPtr< OdGiVariant > | createObject (double value) |
static OdSmartPtr< OdGiVariant > | createObject (const OdCmEntityColor &value) |
static OdSmartPtr< OdGiVariant > | createObject (const OdString &value) |
static OdSmartPtr< OdGiVariant > | createObject (const OdChar *value) |
static bool | isEquivalent (const OdGiVariant *v1, const OdGiVariant *v2) |
Static Public Member Functions inherited from OdRxObject | |
static OdRxObjectPtr | cast (const OdRxObject *pointer) |
static OdRxClass * | desc () |
Protected Member Functions | |
OdGiVariant () | |
This class is used as the basis for the generic data storage used for procedural material definitions.
<group OdGi_Classes>
Definition at line 46 of file GiVariant.h.
Defines the current type set to an OdGiVariant object.
Enumerator | |
---|---|
kUndefined | |
kBoolean | |
kInt | |
kDouble | |
kColor | |
kString | |
kTable |
Definition at line 53 of file GiVariant.h.
|
protected |
OdGiVariant::~OdGiVariant | ( | ) |
bool OdGiVariant::asBoolean | ( | ) | const |
Returns the current value if the variant type is kBoolean. For other types the method throws an exception.
OdInt8 OdGiVariant::asChar | ( | ) | const |
Returns the current value as a char. The method calls the asInt() and casts the result to a char.
const OdCmEntityColor& OdGiVariant::asColor | ( | ) | const |
Returns the current value if the variant type is kColor. For other types the method throws an exception.
double OdGiVariant::asDouble | ( | ) | const |
Returns the current value if the variant type is kDouble. For other types the method throws an exception.
EnumType OdGiVariant::asEnum | ( | ) | const |
Returns the current value as an EnumType. The method calls the asInt() and creates an OdGiVariant::EnumType from the result.
float OdGiVariant::asFloat | ( | ) | const |
Returns the current value as a float. The method calls the asDouble() and casts the result to a float.
OdInt32 OdGiVariant::asInt | ( | ) | const |
Returns the current value if the variant type is kInt. For other types the method throws an exception.
OdInt32 OdGiVariant::asLong | ( | ) | const |
Returns the current value as a long. The method is equivalent to asInt().
OdInt16 OdGiVariant::asShort | ( | ) | const |
Returns the current value as a short. The method calls the asInt() and casts the result to a short.
const OdString& OdGiVariant::asString | ( | ) | const |
Returns the current value if the variant type is kString. For other types the method throws an exception.
OdUInt8 OdGiVariant::asUchar | ( | ) | const |
Returns the current value as an unsigned char. The method calls the asInt() and casts the result to an unsigned char.
OdUInt32 OdGiVariant::asUint | ( | ) | const |
Returns the current value as an unsigned long. The method calls the asInt() and casts the result to an unsigned long.
OdUInt32 OdGiVariant::asUlong | ( | ) | const |
Returns the current value as an unsigned long. The method is equivalent to asUint().
OdUInt16 OdGiVariant::asUshort | ( | ) | const |
Returns the current value as an unsigned short. The method calls the asInt() and casts the result to an unsigned short.
|
virtual |
Copies the contents of the specified object into this object.
pSource | [in] Pointer to the source object. |
Throws:
Cause eNotApplicable The incoming object isn't of type OdGiVariant. eNullObjectPointer The incoming object is null.
Reimplemented from OdRxObject.
|
static |
Creates a new OdGiVariant object of the kBoolean type and initializes it with an input boolean value.
value | [in] Input initial boolean value. |
|
static |
Creates a new OdGiVariant object of the kString type and initializes it with a string of an input char array.
value | [in] Input initial char array. |
|
static |
Creates a new OdGiVariant object of the kColor type and initializes it with an input color value.
value | [in] Input initial color value. |
|
static |
This constructor creates an empty OdGiVariant instance and copies an input OdGiVariant into it.
value | [in] Reference to an existing OdGiVariant to copy. |
|
static |
Creates a new OdGiVariant object of the kString type and initializes it with an input string.
value | [in] Input initial string value. |
|
static |
Creates a new OdGiVariant object of the kDouble type and initializes it with an input floating point value.
value | [in] Input initial floating point value. |
|
static |
Creates a new OdGiVariant object of the kInt type and initializes it with an input long value.
value | [in] Input initial long value. |
If the variant's type is kTable, deletes the element with the specified string key from the table. For other types the method is invalid.
elem | [in] Input string key with which to add the value. |
const OdGiVariant* OdGiVariant::getElem | ( | const OdString & | elem | ) | const |
If the variant's type is kTable, gets the value paired with the specified string key. For other types the method is invalid.
elem | [in] Input string key of an element in the table. |
bool OdGiVariant::getElem | ( | const OdString & | elem, |
OdGiVariant & | value | ||
) | const |
If the variant's type is kTable, gets the value paired with the specified string key. For other types the method is invalid.
value | [in] Input reference to an OdGiVariant object to be filled with the retrieved value. |
elem | [in] Input string key of an element in the table. |
const OdGiVariant* OdGiVariant::getElemAt | ( | OdInt32 | nElem, |
OdString & | elem | ||
) | const |
If the variant's type is kTable, gets the key and a pointer to the OdGiVariant value from the table by the specified index. For other types the method is invalid.
nElem | [in] Input index. Should be within the limits of the table size. |
elem | [out] Output string key at the nElem index. |
bool OdGiVariant::getElemAt | ( | OdInt32 | nElem, |
OdString & | elem, | ||
OdGiVariant & | value | ||
) | const |
If the variant's type is kTable, gets the key and OdGiVariant value from the table by the specified index. For other types the method is invalid.
nElem | [in] Input index. Should be within the limits of the table size. |
value | [out] Output OdGiVariant value at the nElem index. |
elem | [out] Output string key at the nElem index. |
OdInt32 OdGiVariant::getElemCount | ( | ) | const |
If the variant's type is kTable, returns the number of table's elements. For other types the method is invalid.
|
static |
Determines whether two OdGiVariant objects are equivalent by checking the types and values. For table elements, verifies equivalence of each element by its key.
v1 - first input OdGiVariant object. v2 - second input OdGiVariant object.
OdGiVariant::ODRX_DECLARE_MEMBERS | ( | OdGiVariant | ) |
OdGiVariant& OdGiVariant::operator= | ( | const OdGiVariant & | value | ) |
bool OdGiVariant::operator== | ( | const OdGiVariant & | value | ) | const |
void OdGiVariant::set | ( | bool | value | ) |
Changes the OdGiVariant's type to kBoolean and assigns a new value.
value | [in] Input new boolean value to set. |
Changes the OdGiVariant's type to kString and assigns a new value.
value | [in] Input new char array to set as a string value. |
void OdGiVariant::set | ( | const OdCmEntityColor & | value | ) |
Changes the OdGiVariant's type to kColor and assigns a new value.
value | [in] Input new color value to set. |
Changes the OdGiVariant's type to kString and assigns a new value.
value | [in] Input new string value to set. |
void OdGiVariant::set | ( | double | value | ) |
Changes the OdGiVariant's type to kDouble and assigns a new value.
value | [in] Input new floating point value to set. |
Changes the OdGiVariant's type to kInt and assigns a new value.
value | [in] Input new long value to set. |
void OdGiVariant::setElem | ( | const OdString & | elem, |
const OdGiVariant & | value | ||
) |
Adds the specified value to the table with the specified string key. If the object isn't of the kTable type, the method converts the type to kTable.
value | [in] Value to be added with the elem key. |
elem | [in] Input string key with which to add the value. |
VariantType OdGiVariant::type | ( | ) | const |
Returns the current type of the OdGiVariant object. All available types are defined in the VariantType enumeration.