![]() |
GenericContainer
GenericContaine a tool for C++ programming
|
A class implementing a simple Lua interpreter. More...
#include <GenericContainerInterface_lua.hh>
Public Member Functions | |
LuaInterpreter () | |
Constructor that initializes the Lua interpreter. | |
~LuaInterpreter () | |
Destructor that closes the Lua interpreter. | |
void | execute (char const cmd[]) |
Execute a Lua command string. | |
void | call (GenericContainer const &arguments, GenericContainer &res) |
Call a Lua function with arguments from a GenericContainer . | |
void | do_file (char const fname[]) |
Load and execute a Lua script file. | |
void | GC_to_global (GenericContainer const &gc, char const global_var[]) |
Store a GenericContainer as a Lua global variable. | |
void | global_to_GC (char const var[], GenericContainer &gc) |
Convert a Lua global variable into a GenericContainer . | |
int | interactive (int argc, char const **argv, char const **messages, char const *prompt) |
Launch an interactive Lua interpreter mode. | |
A class implementing a simple Lua interpreter.
The LuaInterpreter
class provides an interface for loading and executing Lua scripts, as well as interacting with Lua global variables using the GenericContainer
.
GC_namespace::LuaInterpreter::LuaInterpreter | ( | ) |
Constructor that initializes the Lua interpreter.
GC_namespace::LuaInterpreter::~LuaInterpreter | ( | ) |
Destructor that closes the Lua interpreter.
void GC_namespace::LuaInterpreter::call | ( | GenericContainer const & | arguments, |
GenericContainer & | res ) |
Call a Lua function with arguments from a GenericContainer
.
This function invokes a Lua function and passes the arguments stored in a GenericContainer
. The result of the function is returned in another GenericContainer
.
[in] | arguments | GenericContainer containing the Lua function name and arguments. |
[out] | res | GenericContainer where the result of the Lua function will be stored. |
void GC_namespace::LuaInterpreter::do_file | ( | char const | fname[] | ) |
Load and execute a Lua script file.
This function reads and executes a Lua script from a file.
[in] | fname | Name of the Lua script file. |
void GC_namespace::LuaInterpreter::execute | ( | char const | cmd[] | ) |
Execute a Lua command string.
This function allows you to run arbitrary Lua code passed as a string.
[in] | cmd | Lua command to execute. |
|
inline |
Store a GenericContainer
as a Lua global variable.
This function converts a GenericContainer
into a Lua global variable.
[in] | gc | The GenericContainer to convert. |
[in] | global_var | Name of the Lua global variable. |
|
inline |
Convert a Lua global variable into a GenericContainer
.
This function retrieves a Lua global variable and converts it into a GenericContainer
.
[in] | var | Name of the Lua global variable. |
[out] | gc | GenericContainer where the Lua variable will be stored. |
int GC_namespace::LuaInterpreter::interactive | ( | int | argc, |
char const ** | argv, | ||
char const ** | messages, | ||
char const * | prompt ) |
Launch an interactive Lua interpreter mode.
This function starts an interactive Lua session, allowing users to enter and execute Lua commands.
[in] | argc | Number of arguments. |
[in] | argv | List of command-line arguments. |
[in] | messages | List of messages to display during the session. |
[in] | prompt | Prompt string to display for the user. |