89 virtual bool doFile(
const std::string& filename);
94 virtual bool doScript(
const std::string& data);
101 template <
typename RT>
102 RT
get(
int stackIndex);
110 template <
typename RT>
111 RT
get(
const std::string& name,
bool resolveDots =
true);
117 template <
typename T>
118 void push(
const T& data);
125 template <
typename T>
126 bool store(
const std::string& name,
const T& data);
150 template <
typename T>
156 template <
typename T>
210template <
typename RT>
214 DecoderMap::iterator iter =
theDecoders.find(
typeid(RT).name());
217 std::string error = std::string(
"Cannot find data type decoder for type") + std::string(
typeid(RT).name());
226template <
typename RT>
238 EncoderMap::iterator iter =
theEncoders.find(
typeid(T).name());
241 std::string error = std::string(
"Cannot find data type encoder for type") + std::string(
typeid(T).name());
Provides assertion macros and functions for error detection and handling.
#define DtASSERT(exp, description)
Primary assertion macro for runtime validation.
Definition assert.h:53
Base class for all Lua to C++ decoders.
Definition luaEncoderDecoder.h:30
Base class for all C++ to Lua encoders.
Definition luaEncoderDecoder.h:59
Represents a Lua object (typically a table) in C++.
Definition luaObject.h:37
A utility class for automatically cleaning the Lua stack.
Definition luaStackCleaner.h:28
virtual bool hasObject(const std::string &name)
Checks if an object exists in the Lua state.
bool myNeedToCloseState
Flag indicating if the state should be closed on destruction.
Definition luaState.h:186
static bool theInitializedEncoderDecoders
Flag indicating if encoders and decoders have been initialized.
Definition luaState.h:207
static void addDecoder(DtBaseDecoder *decoder)
Registers a decoder for a specific C++ type.
virtual DtLuaObject findObject(const std::string &name)
Finds and returns a Lua object.
virtual bool getItemOnStack(const std::string &name, bool resolveDots=true)
Retrieves a named item and pushes it onto the stack.
DtLuaState & operator=(const DtLuaState &orig)
Assignment operator.
void push(const T &data)
Pushes a C++ value onto the Lua stack.
Definition luaState.h:236
static void addEncoder(DtBaseEncoder *encoder)
Registers an encoder for a specific C++ type.
virtual int stackSize()
Gets the current size of the Lua stack.
DtLuaState(lua_State &L)
Constructor with existing Lua state.
RT get(int stackIndex)
Gets a value from the Lua stack and converts it to a C++ type.
Definition luaState.h:211
virtual void forceGarbageCollection()
Forces a full Lua garbage collection cycle.
virtual bool doFile(const std::string &filename)
Executes a Lua script from a file.
virtual void printValue(int index)
Prints a single value from the stack for debugging.
virtual void stackDump()
Dumps the contents of the Lua stack for debugging.
DtLuaState(const DtLuaState &orig)
Copy constructor (not implemented)
lua_State * myState
Pointer to the Lua state.
Definition luaState.h:183
virtual ~DtLuaState()
Virtual destructor.
virtual void printTable(int index)
Prints a table from the stack for debugging.
static EncoderMap theEncoders
Static map of type names to encoder implementations.
Definition luaState.h:195
lua_State * state()
Gets the underlying Lua state.
static DecoderMap theDecoders
Static map of type names to decoder implementations.
Definition luaState.h:198
std::map< std::string, DtBaseDecoder * > DecoderMap
Type definition for the decoder registry map.
Definition luaState.h:192
bool store(const std::string &name, const T &data)
Stores a C++ value as a named variable in Lua.
virtual void clearStack()
Clears the Lua stack.
static void initDecoders()
Initializes the standard decoders.
DtLuaState()
Default constructor.
std::map< std::string, DtBaseEncoder * > EncoderMap
Type definition for the encoder registry map.
Definition luaState.h:189
virtual bool topStackValueOk()
Checks if the top stack value is valid.
virtual bool doScript(const std::string &data)
Executes a Lua script from a string.
static void initEncoders()
Initializes the standard encoders.
virtual DtLuaObject createTable(int narr=0, int nrec=0)
Creates a new Lua table.
Type-specific decoder for converting Lua values to C++ values.
Definition luaEncoderDecoder.h:46
virtual T get(lua_State *state, int index)
Converts a Lua value to a C++ value.
Type-specific encoder for converting C++ values to Lua values.
Definition luaEncoderDecoder.h:76
virtual void push(lua_State *state, const T &data)
Pushes a C++ value onto the Lua stack.
Defines export macros for the VREngage Utility library.
#define UTIL_DLL
Export/import macro for non-Windows platforms.
Definition export.h:39
Provides type conversion between C++ and Lua.
Provides access to Lua tables and objects with C++ wrappers.
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
int UTIL_DLL DtLuaErrorHandler(lua_State *L)
Error handler function for Lua errors.