Graphite  Version 3
An experimental 3D geometry processing program
GEO::lua_to< T > Class Template Reference

Converts LUA variables to C++ variables. More...

#include <geogram/lua/lua_wrap.h>

Public Member Functions

 lua_to (lua_State *L, int idx)
 lua_to constructor. More...
 
 operator T () const
 Gets the converted value. More...
 

Static Public Member Functions

static bool can_convert (lua_State *L, int idx)
 Tests whether a LUA variable can be converted to a C++ variable. More...
 

Protected Attributes

x_
 

Detailed Description

template<class T>
class GEO::lua_to< T >

Converts LUA variables to C++ variables.

This version is a placeholder, the actual implementation is done in the template specializations.

Definition at line 243 of file lua_wrap.h.

Constructor & Destructor Documentation

◆ lua_to()

template<class T >
GEO::lua_to< T >::lua_to ( lua_State *  L,
int  idx 
)
inline

lua_to constructor.

Does the actual conversion. The converted variable is memorized in a member. It can be accesed by a conversion operator. Supposing that my_function() takes a std::string and an int as arguments, it can be called as follows:

my_function(lua_to<std::string>(L,1), lua_to<int>(L,2));
Parameters
[in]La pointer to the LUA state.
[in]idxthe index of the variable to be converted.

Definition at line 257 of file lua_wrap.h.

Member Function Documentation

◆ can_convert()

template<class T >
static bool GEO::lua_to< T >::can_convert ( lua_State *  L,
int  idx 
)
inlinestatic

Tests whether a LUA variable can be converted to a C++ variable.

Note
It would have been possible to make the constructor throw an exception on conversion error, but exceptions are not well supported by Emscripten so we have separated validity check from conversion.
Parameters
[in]La pointer to the LUA state.
[in]idxthe index of the variable to be converted.
Return values
trueif the LUA variable can be converted to a C++ variable.
falseotherwise.

Definition at line 275 of file lua_wrap.h.

◆ operator T()

template<class T >
GEO::lua_to< T >::operator T ( ) const
inline

Gets the converted value.

Returns
the converted value.

Definition at line 285 of file lua_wrap.h.


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