Kanzi 3.9.10
kanzi::LuaInstance Class Reference

Loads and runs Lua scripts. More...

#include <kanzi/lua/lua_instance.hpp>

Public Member Functions

bool loadScript (BinaryResource &resource)
 Loads a binary resource as a Lua script.
 
bool loadScript (string_view scriptName, string_view code)
 Loads a Lua script and assigns a name to the script.
 
void run (const BinaryResource &resource)
 Runs a previously loaded resource loaded as a Lua script.
 
void run (const BinaryResource &resource, NodeSharedPtr contextNode)
 Runs a previously loaded resource loaded as a Lua script.
 
void run (string_view scriptName)
 Runs a previously loaded Lua script with a matching name.
 
void run (string_view scriptName, NodeSharedPtr contextNode)
 Runs a previously loaded Lua script with a matching name.
 
 ~LuaInstance ()
 Destructor.
 

Static Public Attributes

static PropertyType< intLuaInstanceIDProperty
 Set to binary resources of scripts that are loaded into the Lua instance.
 

Friends

class LuaModule
 Friend classes.
 

Detailed Description

Loads and runs Lua scripts.

Use the LuaModule to initialize, retrieve, and free the LuaInstance.

See also
LuaModule
Since
Kanzi 3.9.9

Constructor & Destructor Documentation

◆ ~LuaInstance()

kanzi::LuaInstance::~LuaInstance ( )

Destructor.

Member Function Documentation

◆ run() [1/4]

void kanzi::LuaInstance::run ( string_view scriptName)

Runs a previously loaded Lua script with a matching name.

Parameters
scriptNameName of the script to be run. If nullopt, runs the latest loaded Lua script.

◆ run() [2/4]

void kanzi::LuaInstance::run ( string_view scriptName,
NodeSharedPtr contextNode )

Runs a previously loaded Lua script with a matching name.

Parameters
scriptNameName of the script to be run.
contextNodeThe context node attached to the script.

◆ run() [3/4]

void kanzi::LuaInstance::run ( const BinaryResource & resource)

Runs a previously loaded resource loaded as a Lua script.

Parameters
resourceThe binary resource that contains the Lua script to run.

◆ run() [4/4]

void kanzi::LuaInstance::run ( const BinaryResource & resource,
NodeSharedPtr contextNode )

Runs a previously loaded resource loaded as a Lua script.

Parameters
resourceThe binary resource that contains the Lua script to run.
contextNodeThe context node attached to the script.

◆ loadScript() [1/2]

bool kanzi::LuaInstance::loadScript ( string_view scriptName,
string_view code )

Loads a Lua script and assigns a name to the script.

When you assign a name that is already in use by another script, the script replaces the previously loaded script.

Parameters
codeLua script to load.
scriptNameName of the script.
Returns
True if the script is loaded.

◆ loadScript() [2/2]

bool kanzi::LuaInstance::loadScript ( BinaryResource & resource)

Loads a binary resource as a Lua script.

The script does not load the script if is already loaded. The name of the script is the resource URL.

Parameters
resourceThe binary resource that contains the Lua script.
Returns
True if the binary resource is loaded as a Lua script.

Friends And Related Symbol Documentation

◆ LuaModule

Friend classes.

Member Data Documentation

◆ LuaInstanceIDProperty

PropertyType<int> kanzi::LuaInstance::LuaInstanceIDProperty
static

Set to binary resources of scripts that are loaded into the Lua instance.


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