CFx SDK Documentation  2020SP3
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
OdGiVariant Class Reference

#include <GiVariant.h>

Inheritance diagram for OdGiVariant:
OdRxObject OdStaticRxObject< OdGiVariant >

Classes

class  EnumType
 

Public Types

enum  VariantType {
  kUndefined = 0, kBoolean, kInt, kDouble,
  kColor, kString, kTable
}
 

Public Member Functions

 ODRX_DECLARE_MEMBERS (OdGiVariant)
 
 ~OdGiVariant ()
 
bool operator== (const OdGiVariant &value) const
 
OdGiVariantoperator= (const OdGiVariant &value)
 
virtual void copyFrom (const OdRxObject *pSource)
 
VariantType type () const
 
void set (bool value)
 
void set (OdInt32 value)
 
void set (double value)
 
void set (const OdCmEntityColor &value)
 
void set (const OdString &value)
 
void set (const OdChar *value)
 
bool asBoolean () const
 
OdInt32 asInt () const
 
double asDouble () const
 
const OdCmEntityColorasColor () const
 
const OdStringasString () const
 
float asFloat () const
 
OdInt8 asChar () const
 
OdUInt8 asUchar () const
 
OdInt16 asShort () const
 
OdUInt16 asUshort () const
 
OdUInt32 asUint () const
 
OdInt32 asLong () const
 
OdUInt32 asUlong () const
 
EnumType asEnum () const
 
bool getElem (const OdString &elem, OdGiVariant &value) const
 
const OdGiVariantgetElem (const OdString &elem) const
 
void setElem (const OdString &elem, const OdGiVariant &value)
 
void deleteElem (const OdString &elem)
 
OdInt32 getElemCount () const
 
bool getElemAt (OdInt32 nElem, OdString &elem, OdGiVariant &value) const
 
const OdGiVariantgetElemAt (OdInt32 nElem, OdString &elem) const
 
- Public Member Functions inherited from OdRxObject
 ODRX_HEAP_OPERATORS ()
 
 OdRxObject ()
 
virtual ~OdRxObject ()
 
virtual OdRxObjectqueryX (const OdRxClass *pClass) const
 
virtual OdRxObjectx (const OdRxClass *pClass) const
 
virtual OdRxClassisA () const
 
virtual void addRef ()=0
 
virtual void release ()=0
 
virtual long numRefs () const
 
bool isKindOf (const OdRxClass *pClass) const
 
virtual OdRxObjectPtr clone () const
 
virtual OdRx::Ordering comparedTo (const OdRxObject *pOther) const
 
virtual bool isEqualTo (const OdRxObject *pOther) const
 

Static Public Member Functions

static OdSmartPtr< OdGiVariantcreateObject (const OdGiVariant &value)
 
static OdSmartPtr< OdGiVariantcreateObject (bool value)
 
static OdSmartPtr< OdGiVariantcreateObject (OdInt32 value)
 
static OdSmartPtr< OdGiVariantcreateObject (double value)
 
static OdSmartPtr< OdGiVariantcreateObject (const OdCmEntityColor &value)
 
static OdSmartPtr< OdGiVariantcreateObject (const OdString &value)
 
static OdSmartPtr< OdGiVariantcreateObject (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 OdRxClassdesc ()
 

Protected Member Functions

 OdGiVariant ()
 

Detailed Description

This class is used as the basis for the generic data storage used for procedural material definitions.

See also
TD_Gi

<group OdGi_Classes>

Definition at line 46 of file GiVariant.h.

Member Enumeration Documentation

◆ VariantType

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.

Constructor & Destructor Documentation

◆ OdGiVariant()

OdGiVariant::OdGiVariant ( )
protected

◆ ~OdGiVariant()

OdGiVariant::~OdGiVariant ( )

Member Function Documentation

◆ asBoolean()

bool OdGiVariant::asBoolean ( ) const

Returns the current value if the variant type is kBoolean. For other types the method throws an exception.

◆ asChar()

OdInt8 OdGiVariant::asChar ( ) const

Returns the current value as a char. The method calls the asInt() and casts the result to a char.

◆ asColor()

const OdCmEntityColor& OdGiVariant::asColor ( ) const

Returns the current value if the variant type is kColor. For other types the method throws an exception.

◆ asDouble()

double OdGiVariant::asDouble ( ) const

Returns the current value if the variant type is kDouble. For other types the method throws an exception.

◆ asEnum()

EnumType OdGiVariant::asEnum ( ) const

Returns the current value as an EnumType. The method calls the asInt() and creates an OdGiVariant::EnumType from the result.

◆ asFloat()

float OdGiVariant::asFloat ( ) const

Returns the current value as a float. The method calls the asDouble() and casts the result to a float.

◆ asInt()

OdInt32 OdGiVariant::asInt ( ) const

Returns the current value if the variant type is kInt. For other types the method throws an exception.

◆ asLong()

OdInt32 OdGiVariant::asLong ( ) const

Returns the current value as a long. The method is equivalent to asInt().

◆ asShort()

OdInt16 OdGiVariant::asShort ( ) const

Returns the current value as a short. The method calls the asInt() and casts the result to a short.

◆ asString()

const OdString& OdGiVariant::asString ( ) const

Returns the current value if the variant type is kString. For other types the method throws an exception.

◆ asUchar()

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.

◆ asUint()

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.

◆ asUlong()

OdUInt32 OdGiVariant::asUlong ( ) const

Returns the current value as an unsigned long. The method is equivalent to asUint().

◆ asUshort()

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.

◆ copyFrom()

virtual void OdGiVariant::copyFrom ( const OdRxObject pSource)
virtual

Copies the contents of the specified object into this object.

Parameters
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.

◆ createObject() [1/7]

static OdSmartPtr<OdGiVariant> OdGiVariant::createObject ( bool  value)
static

Creates a new OdGiVariant object of the kBoolean type and initializes it with an input boolean value.

Parameters
value[in] Input initial boolean value.

◆ createObject() [2/7]

static OdSmartPtr<OdGiVariant> OdGiVariant::createObject ( const OdChar value)
static

Creates a new OdGiVariant object of the kString type and initializes it with a string of an input char array.

Parameters
value[in] Input initial char array.

◆ createObject() [3/7]

static OdSmartPtr<OdGiVariant> OdGiVariant::createObject ( const OdCmEntityColor value)
static

Creates a new OdGiVariant object of the kColor type and initializes it with an input color value.

Parameters
value[in] Input initial color value.

◆ createObject() [4/7]

static OdSmartPtr<OdGiVariant> OdGiVariant::createObject ( const OdGiVariant value)
static

This constructor creates an empty OdGiVariant instance and copies an input OdGiVariant into it.

Parameters
value[in] Reference to an existing OdGiVariant to copy.

◆ createObject() [5/7]

static OdSmartPtr<OdGiVariant> OdGiVariant::createObject ( const OdString value)
static

Creates a new OdGiVariant object of the kString type and initializes it with an input string.

Parameters
value[in] Input initial string value.

◆ createObject() [6/7]

static OdSmartPtr<OdGiVariant> OdGiVariant::createObject ( double  value)
static

Creates a new OdGiVariant object of the kDouble type and initializes it with an input floating point value.

Parameters
value[in] Input initial floating point value.

◆ createObject() [7/7]

static OdSmartPtr<OdGiVariant> OdGiVariant::createObject ( OdInt32  value)
static

Creates a new OdGiVariant object of the kInt type and initializes it with an input long value.

Parameters
value[in] Input initial long value.

◆ deleteElem()

void OdGiVariant::deleteElem ( const OdString elem)

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.

Parameters
elem[in] Input string key with which to add the value.

◆ getElem() [1/2]

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.

Parameters
elem[in] Input string key of an element in the table.
Returns
A pointer to the obtained OdGiVariant object. If the value isn't retrieved, returns NULL.

◆ getElem() [2/2]

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.

Parameters
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.
Returns
true if value is successfully retrieved, false - otherwise.

◆ getElemAt() [1/2]

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.

Parameters
nElem[in] Input index. Should be within the limits of the table size.
elem[out] Output string key at the nElem index.
Returns
A pointer to the obtained OdGiVariant value. If the value isn't retrieved, returns NULL.

◆ getElemAt() [2/2]

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.

Parameters
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.
Returns
true - if the key and value are retrieved successfully. false - otherwise.

◆ getElemCount()

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.

◆ isEquivalent()

static bool OdGiVariant::isEquivalent ( const OdGiVariant v1,
const OdGiVariant v2 
)
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.

Returns
true - if two objects are equivalent. false - otherwise.

◆ ODRX_DECLARE_MEMBERS()

OdGiVariant::ODRX_DECLARE_MEMBERS ( OdGiVariant  )

◆ operator=()

OdGiVariant& OdGiVariant::operator= ( const OdGiVariant value)

◆ operator==()

bool OdGiVariant::operator== ( const OdGiVariant value) const

◆ set() [1/6]

void OdGiVariant::set ( bool  value)

Changes the OdGiVariant's type to kBoolean and assigns a new value.

Parameters
value[in] Input new boolean value to set.

◆ set() [2/6]

void OdGiVariant::set ( const OdChar value)

Changes the OdGiVariant's type to kString and assigns a new value.

Parameters
value[in] Input new char array to set as a string value.

◆ set() [3/6]

void OdGiVariant::set ( const OdCmEntityColor value)

Changes the OdGiVariant's type to kColor and assigns a new value.

Parameters
value[in] Input new color value to set.

◆ set() [4/6]

void OdGiVariant::set ( const OdString value)

Changes the OdGiVariant's type to kString and assigns a new value.

Parameters
value[in] Input new string value to set.

◆ set() [5/6]

void OdGiVariant::set ( double  value)

Changes the OdGiVariant's type to kDouble and assigns a new value.

Parameters
value[in] Input new floating point value to set.

◆ set() [6/6]

void OdGiVariant::set ( OdInt32  value)

Changes the OdGiVariant's type to kInt and assigns a new value.

Parameters
value[in] Input new long value to set.

◆ setElem()

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.

Parameters
value[in] Value to be added with the elem key.
elem[in] Input string key with which to add the value.

◆ type()

VariantType OdGiVariant::type ( ) const

Returns the current type of the OdGiVariant object. All available types are defined in the VariantType enumeration.


The documentation for this class was generated from the following file: