VR-Engage  2.2
Loading...
Searching...
No Matches
makVre::DtLuaValue Class Reference

Detailed Description

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>

Inheritance diagram for makVre::DtLuaValue:
[legend]

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)
 
DtLuaValueoperator= (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 
 
};  
 

Member Enumeration Documentation

◆ ScriptDataTypeEnum

Enumeration of supported Lua value types.

This enumeration defines the types of Lua values that can be represented by the DtLuaValue class.

Enumerator
SCRIPT_NIL 

Nil value (null/undefined)

SCRIPT_BOOL 

Boolean value (true/false)

SCRIPT_INT 

Integer value.

SCRIPT_FLOAT 

Single-precision floating point value.

SCRIPT_DOUBLE 

Double-precision floating point value.

SCRIPT_STRING 

String value.

SCRIPT_POINTER 

Pointer value (for light userdata)

SCRIPT_FUNCTION 

Function reference.

SCRIPT_TABLE 

Table reference.

Constructor & Destructor Documentation

◆ DtLuaValue() [1/9]

makVre::DtLuaValue::DtLuaValue ( )

Default constructor.

Creates a nil value

Referenced by DtLuaValue(), and operator=().

◆ DtLuaValue() [2/9]

makVre::DtLuaValue::DtLuaValue ( bool v)

Constructor for boolean values.

Parameters
vBoolean value to store

◆ DtLuaValue() [3/9]

makVre::DtLuaValue::DtLuaValue ( int v)

Constructor for integer values.

Parameters
vInteger value to store

◆ DtLuaValue() [4/9]

makVre::DtLuaValue::DtLuaValue ( float v)

Constructor for float values.

Parameters
vFloat value to store

◆ DtLuaValue() [5/9]

makVre::DtLuaValue::DtLuaValue ( double v)

Constructor for double values.

Parameters
vDouble value to store

◆ DtLuaValue() [6/9]

makVre::DtLuaValue::DtLuaValue ( const std::string & v)

Constructor for string values.

Parameters
vString value to store

◆ DtLuaValue() [7/9]

makVre::DtLuaValue::DtLuaValue ( const char * v)

Constructor for C-string values.

Parameters
vC-string value to store

◆ DtLuaValue() [8/9]

makVre::DtLuaValue::DtLuaValue ( void * v)

Constructor for pointer values.

Parameters
vPointer value to store

◆ ~DtLuaValue()

virtual makVre::DtLuaValue::~DtLuaValue ( )
virtual

Virtual destructor.

◆ DtLuaValue() [9/9]

makVre::DtLuaValue::DtLuaValue ( const DtLuaValue & orig)

Copy constructor.

Parameters
origSource object to copy from

References DtLuaValue().

Member Function Documentation

◆ operator=()

DtLuaValue & makVre::DtLuaValue::operator= ( const DtLuaValue & orig)

Assignment operator.

Parameters
origSource object to assign from
Returns
Reference to this object

References DtLuaValue().

◆ type()

virtual ScriptDataTypeEnum makVre::DtLuaValue::type ( ) const
virtual

Gets the type of this Lua value.

Returns
Enumeration value indicating the type

◆ isNil()

virtual bool makVre::DtLuaValue::isNil ( ) const
virtual

Checks if this value is nil.

Returns
True if the value is nil, false otherwise

◆ isBool()

virtual bool makVre::DtLuaValue::isBool ( ) const
virtual

Checks if this value is a boolean.

Returns
True if the value is a boolean, false otherwise

◆ isInt()

virtual bool makVre::DtLuaValue::isInt ( ) const
virtual

Checks if this value is an integer.

Returns
True if the value is an integer, false otherwise

◆ isFloat()

virtual bool makVre::DtLuaValue::isFloat ( ) const
virtual

Checks if this value is a float.

Returns
True if the value is a float, false otherwise

◆ isDouble()

virtual bool makVre::DtLuaValue::isDouble ( ) const
virtual

Checks if this value is a double.

Returns
True if the value is a double, false otherwise

◆ isString()

virtual bool makVre::DtLuaValue::isString ( ) const
virtual

Checks if this value is a string.

Returns
True if the value is a string, false otherwise

◆ isPointer()

virtual bool makVre::DtLuaValue::isPointer ( ) const
virtual

Checks if this value is a pointer.

Returns
True if the value is a pointer, false otherwise

◆ isTable()

virtual bool makVre::DtLuaValue::isTable ( ) const
virtual

Checks if this value is a table.

Returns
True if the value is a table, false otherwise

◆ isFunction()

virtual bool makVre::DtLuaValue::isFunction ( ) const
virtual

Checks if this value is a function.

Returns
True if the value is a function, false otherwise

◆ boolValue()

virtual bool makVre::DtLuaValue::boolValue ( ) const
virtual

Gets the value as a boolean.

Returns
The boolean value
Note
May perform type conversion if the underlying type is not boolean

◆ intValue()

virtual int makVre::DtLuaValue::intValue ( ) const
virtual

Gets the value as an integer.

Returns
The integer value
Note
May perform type conversion if the underlying type is not integer

◆ floatValue()

virtual float makVre::DtLuaValue::floatValue ( ) const
virtual

Gets the value as a float.

Returns
The float value
Note
May perform type conversion if the underlying type is not float

◆ doubleValue()

virtual double makVre::DtLuaValue::doubleValue ( ) const
virtual

Gets the value as a double.

Returns
The double value
Note
May perform type conversion if the underlying type is not double

◆ stringValue()

virtual std::string makVre::DtLuaValue::stringValue ( ) const
virtual

Gets the value as a string.

Returns
The string value
Note
May perform type conversion if the underlying type is not string

◆ pointerValue()

virtual void * makVre::DtLuaValue::pointerValue ( ) const
virtual

Gets the value as a pointer.

Returns
The pointer value
Note
Returns nullptr if the underlying type is not a pointer

◆ typeName()

virtual std::string makVre::DtLuaValue::typeName ( ) const
virtual

Gets the name of the value's type as a string.

Returns
String representation of the value's type

Member Data Documentation

◆ myType

ScriptDataTypeEnum makVre::DtLuaValue::myType
protected

The type of the stored value.

Referenced by makVre::DtLuaObject::setField(), and makVre::DtLuaObject::setField().

◆ myBool

bool makVre::DtLuaValue::myBool

Storage for boolean values.

◆ myInt

int makVre::DtLuaValue::myInt

Storage for integer values.

◆ myFloat

float makVre::DtLuaValue::myFloat

Storage for float values.

◆ myDouble

double makVre::DtLuaValue::myDouble

Storage for double values.

◆ myString

const char* makVre::DtLuaValue::myString

Storage for string values.

◆ myPtr

void* makVre::DtLuaValue::myPtr

Storage for pointer values.

◆ [union]

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.


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