GenericContainer
GenericContaine a tool for C++ programming
Loading...
Searching...
No Matches
GC_namespace::LuaInterpreter Class Reference

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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ LuaInterpreter()

GC_namespace::LuaInterpreter::LuaInterpreter ( )

Constructor that initializes the Lua interpreter.

◆ ~LuaInterpreter()

GC_namespace::LuaInterpreter::~LuaInterpreter ( )

Destructor that closes the Lua interpreter.

Member Function Documentation

◆ call()

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.

Parameters
[in]argumentsGenericContainer containing the Lua function name and arguments.
[out]resGenericContainer where the result of the Lua function will be stored.

◆ do_file()

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.

Parameters
[in]fnameName of the Lua script file.

◆ execute()

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.

Parameters
[in]cmdLua command to execute.

◆ GC_to_global()

void GC_namespace::LuaInterpreter::GC_to_global ( GenericContainer const & gc,
char const global_var[] )
inline

Store a GenericContainer as a Lua global variable.

This function converts a GenericContainer into a Lua global variable.

Parameters
[in]gcThe GenericContainer to convert.
[in]global_varName of the Lua global variable.

◆ global_to_GC()

void GC_namespace::LuaInterpreter::global_to_GC ( char const var[],
GenericContainer & gc )
inline

Convert a Lua global variable into a GenericContainer.

This function retrieves a Lua global variable and converts it into a GenericContainer.

Parameters
[in]varName of the Lua global variable.
[out]gcGenericContainer where the Lua variable will be stored.

◆ interactive()

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.

Parameters
[in]argcNumber of arguments.
[in]argvList of command-line arguments.
[in]messagesList of messages to display during the session.
[in]promptPrompt string to display for the user.
Returns
Status code of the interpreter session.

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