Converts LUA variables to C++ variables.
More...
#include <geogram/lua/lua_wrap.h>
|
static bool | can_convert (lua_State *L, int idx) |
| Tests whether a LUA variable can be converted to a C++ variable. More...
|
|
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.
◆ lua_to()
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] | L | a pointer to the LUA state. |
[in] | idx | the index of the variable to be converted. |
Definition at line 257 of file lua_wrap.h.
◆ 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] | L | a pointer to the LUA state. |
[in] | idx | the index of the variable to be converted. |
- Return values
-
true | if the LUA variable can be converted to a C++ variable. |
false | otherwise. |
Definition at line 275 of file lua_wrap.h.
◆ operator T()
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: