|
VR-Engage
2.2
|
This class provides a C++ representation of Lua values with type information and conversion facilities. It is used for passing values between C++ and Lua, and serves as a base class for more complex Lua object wrappers.
#include <luaValue.h>
Public Types | |
| enum | ScriptDataTypeEnum { SCRIPT_NIL , SCRIPT_BOOL , SCRIPT_INT , SCRIPT_FLOAT , SCRIPT_DOUBLE , SCRIPT_STRING , SCRIPT_POINTER , SCRIPT_FUNCTION , SCRIPT_TABLE } |
Public Member Functions | |
| virtual ScriptDataTypeEnum | type () const |
| virtual std::string | typeName () const |
Constructors and Destructor | |
| DtLuaValue () | |
| DtLuaValue (bool v) | |
| DtLuaValue (int v) | |
| DtLuaValue (float v) | |
| DtLuaValue (double v) | |
| DtLuaValue (const std::string &v) | |
| DtLuaValue (const char *v) | |
| DtLuaValue (void *v) | |
| virtual | ~DtLuaValue () |
Copy and Assignment | |
| DtLuaValue (const DtLuaValue &orig) | |
| DtLuaValue & | operator= (const DtLuaValue &orig) |
Type Checking Methods | |
Methods for checking the type of the value | |
| virtual bool | isNil () const |
| virtual bool | isBool () const |
| virtual bool | isInt () const |
| virtual bool | isFloat () const |
| virtual bool | isDouble () const |
| virtual bool | isString () const |
| virtual bool | isPointer () const |
| virtual bool | isTable () const |
| virtual bool | isFunction () const |
Value Retrieval Methods | |
Methods for retrieving the value with the appropriate type | |
| virtual bool | boolValue () const |
| virtual int | intValue () const |
| virtual float | floatValue () const |
| virtual double | doubleValue () const |
| virtual std::string | stringValue () const |
| virtual void * | pointerValue () const |
Protected Attributes | ||
| ScriptDataTypeEnum | myType | |
| union { | ||
| bool myBool | ||
| int myInt | ||
| float myFloat | ||
| double myDouble | ||
| const char * myString | ||
| void * myPtr | ||
| }; | ||
Enumeration of supported Lua value types.
This enumeration defines the types of Lua values that can be represented by the DtLuaValue class.
| makVre::DtLuaValue::DtLuaValue | ( | ) |
| makVre::DtLuaValue::DtLuaValue | ( | bool | v | ) |
Constructor for boolean values.
| v | Boolean value to store |
| makVre::DtLuaValue::DtLuaValue | ( | int | v | ) |
Constructor for integer values.
| v | Integer value to store |
| makVre::DtLuaValue::DtLuaValue | ( | float | v | ) |
Constructor for float values.
| v | Float value to store |
| makVre::DtLuaValue::DtLuaValue | ( | double | v | ) |
Constructor for double values.
| v | Double value to store |
| makVre::DtLuaValue::DtLuaValue | ( | const std::string & | v | ) |
Constructor for string values.
| v | String value to store |
| makVre::DtLuaValue::DtLuaValue | ( | const char * | v | ) |
Constructor for C-string values.
| v | C-string value to store |
| makVre::DtLuaValue::DtLuaValue | ( | void * | v | ) |
Constructor for pointer values.
| v | Pointer value to store |
|
virtual |
Virtual destructor.
| makVre::DtLuaValue::DtLuaValue | ( | const DtLuaValue & | orig | ) |
| DtLuaValue & makVre::DtLuaValue::operator= | ( | const DtLuaValue & | orig | ) |
Assignment operator.
| orig | Source object to assign from |
References DtLuaValue().
|
virtual |
Gets the type of this Lua value.
|
virtual |
Checks if this value is nil.
|
virtual |
Checks if this value is a boolean.
|
virtual |
Checks if this value is an integer.
|
virtual |
Checks if this value is a float.
|
virtual |
Checks if this value is a double.
|
virtual |
Checks if this value is a string.
|
virtual |
Checks if this value is a pointer.
|
virtual |
Checks if this value is a table.
|
virtual |
Checks if this value is a function.
|
virtual |
Gets the value as a boolean.
|
virtual |
Gets the value as an integer.
|
virtual |
Gets the value as a float.
|
virtual |
Gets the value as a double.
|
virtual |
Gets the value as a string.
|
virtual |
Gets the value as a pointer.
|
virtual |
Gets the name of the value's type as a string.
|
protected |
The type of the stored value.
Referenced by makVre::DtLuaObject::setField(), and makVre::DtLuaObject::setField().
| bool makVre::DtLuaValue::myBool |
Storage for boolean values.
| int makVre::DtLuaValue::myInt |
Storage for integer values.
| float makVre::DtLuaValue::myFloat |
Storage for float values.
| double makVre::DtLuaValue::myDouble |
Storage for double values.
| const char* makVre::DtLuaValue::myString |
Storage for string values.
| void* makVre::DtLuaValue::myPtr |
Storage for pointer values.
| union { ... } makVre::DtLuaValue |
Union storing the actual value.
This union stores the value in its native type to avoid unnecessary conversions. The active member is determined by the myType field.