Lua-API++  2015-02-12-3
Lua-API++ library
State Class Referencefinal

Lua state object. More...

Public Member Functions

Life cycle
 State ()
 Default constructor.
 
 State (void *(__cdecl customAllocatorFunction)(void *ud, void *ptr, size_t oldSize, size_t newSize), void *ud=nullptr)
 Custom allocator constructor.
 
 ~State () noexcept
 Destructor frees the associated Lua state. More...
 
 State (const State &)=delete
 
Stateoperator= (const State &)=delete
 
Environment setup
void runFile (const char *filename)
 Execute Lua file (text or bytecode). More...
 
void runFile (const std::string &filename)
 Execute Lua file (text or bytecode). More...
 
void runString (const char *expression)
 Execute a string. More...
 
void runString (const std::string &expression)
 Execute a string. More...
 
void call (CFunction f)
 Execute C function. More...
 
Direct Lua API interaction
lua_State * getRawState () noexcept
 Access to raw Lua state pointer (for direct use with Lua API).
 

Detailed Description

Lua state object.

State object represents a Lua state. Besides state creation and destruction, it can be used for setting up the environment by executing Lua files, C functions or strings.

Constructor & Destructor Documentation

~State ( )
noexcept

Destructor frees the associated Lua state.

All raw pointers to lua_State are invalidated after object destruction.

State ( const State )
delete

State copying is prohibited.

Member Function Documentation

State& operator= ( const State )
delete

Assignment to State is prohibited

void runFile ( const char *  filename)

Execute Lua file (text or bytecode).

Precondition
filename != nullptr
Exceptions
std::runtime_errorIn case of execution error, what() contains additional information.
void runFile ( const std::string &  filename)
inline

Execute Lua file (text or bytecode).

Exceptions
std::runtime_errorIn case of execution error, what() contains additional information. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void runString ( const char *  expression)

Execute a string.

Precondition
expression != nullptr
Exceptions
std::runtime_errorIn case of execution error, what() contains additional information.
void runString ( const std::string &  expression)
inline

Execute a string.

Exceptions
std::runtime_errorIn case of execution error, what() contains additional information. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void call ( CFunction  f)

Execute C function.

Precondition
f != nullptr
Exceptions
std::runtime_errorIn case of execution error, what() contains additional information.