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

Detailed Description

This class provides table-based access to a Lua state, allowing for retrieval of configuration values from Lua tables. It is primarily used by DtInitializer to access the global '_G' table and other configuration tables.

#include <initializer.h>

Inheritance diagram for makVre::DtInitTable:
[legend]

Public Member Functions

 DtInitTable ()
 
 DtInitTable (lua_State &state, int index, bool throwOnMissingField=true)
 
virtual ~DtInitTable () override
 
template<typename RT>
RT findData (const std::string &name, bool resolveDots=true)
 
template<typename RT>
RT findDataOr (const std::string &name, RT defaultValue, bool silent=false, bool resolveDots=true)
 
template<typename RT>
RT findData (int index)
 
virtual void setThrowOnMissingField (bool set)
 
- Public Member Functions inherited from makVre::DtLuaObject
 DtLuaObject ()
 
 DtLuaObject (lua_State &state, int index)
 
virtual ~DtLuaObject () override
 
 DtLuaObject (const DtLuaObject &orig)
 
DtLuaObjectoperator= (const DtLuaObject &orig)
 
virtual bool operator== (const DtLuaObject &rhs)
 
template<typename RT>
RT get ()
 
virtual void push () const
 
virtual lua_State * state ()
 
virtual std::string serialize ()
 
virtual bool isValid () const
 
virtual bool hasField (const std::string &name, bool resolveDots=true)
 
virtual bool hasField (int index)
 
virtual DtLuaObject operator[] (std::string name)
 
virtual DtLuaObject operator[] (int index)
 
virtual int tableSize ()
 
std::vector< std::string > keys ()
 
template<typename T>
void setField (const std::string &name, const T &val)
 
template<typename T>
void setField (int index, const T &val)
 
- Public Member Functions inherited from makVre::DtLuaValue
virtual ScriptDataTypeEnum type () const
 
virtual std::string typeName () const
 
 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 ()
 
 DtLuaValue (const DtLuaValue &orig)
 
DtLuaValueoperator= (const DtLuaValue &orig)
 
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
 
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

bool myThrowOnMissingField
 
- Protected Attributes inherited from makVre::DtLuaObject
DtLuaReferencemyReference
 
lua_State * myState
 
- Protected Attributes inherited from makVre::DtLuaValue
ScriptDataTypeEnum myType
 
union { 
 
   bool   myBool 
 
   int   myInt 
 
   float   myFloat 
 
   double   myDouble 
 
   const char *   myString 
 
   void *   myPtr 
 
};  
 

Additional Inherited Members

- Public Types inherited from makVre::DtLuaValue
enum  ScriptDataTypeEnum {
  SCRIPT_NIL , SCRIPT_BOOL , SCRIPT_INT , SCRIPT_FLOAT ,
  SCRIPT_DOUBLE , SCRIPT_STRING , SCRIPT_POINTER , SCRIPT_FUNCTION ,
  SCRIPT_TABLE
}
 
- Protected Member Functions inherited from makVre::DtLuaObject
virtual bool getItemOnStack (const std::string &name, bool resolveDots)
 
virtual bool getItemOnStack (int index)
 
virtual void setTable (int index)
 

Constructor & Destructor Documentation

◆ DtInitTable() [1/2]

makVre::DtInitTable::DtInitTable ( )

Default constructor.

Creates an empty initialization table

◆ DtInitTable() [2/2]

makVre::DtInitTable::DtInitTable ( lua_State & state,
int index,
bool throwOnMissingField = true )

Constructor with existing Lua state and table.

Parameters
stateReference to the Lua state containing the table
indexIndex of the table on the Lua stack
throwOnMissingFieldIf true, throws an exception when a requested field is not found

References makVre::DtLuaObject::state().

◆ ~DtInitTable()

virtual makVre::DtInitTable::~DtInitTable ( )
overridevirtual

Destructor.

References findData(), and findDataOr().

Member Function Documentation

◆ findData() [1/2]

template<typename RT>
RT makVre::DtInitTable::findData ( const std::string & name,
bool resolveDots = true )

◆ findDataOr()

template<typename RT>
RT makVre::DtInitTable::findDataOr ( const std::string & name,
RT defaultValue,
bool silent = false,
bool resolveDots = true )

◆ findData() [2/2]

template<typename RT>
RT makVre::DtInitTable::findData ( int index)

◆ setThrowOnMissingField()

virtual void makVre::DtInitTable::setThrowOnMissingField ( bool set)
virtual

Sets whether to throw exceptions for missing fields.

Parameters
setIf true, missing fields will cause exceptions; if false, will return default values

Member Data Documentation

◆ myThrowOnMissingField

bool makVre::DtInitTable::myThrowOnMissingField
protected

Controls exception behavior for missing fields.

When true, missing fields will cause exceptions to be thrown

Referenced by findData(), and findData().


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