Next: slua_tbl_el_s, Previous: slua_tbl_next, Up: Manipulating Tables
get an element from a table
#include <luasup/luasup.h>SLuaError slua_tbl_el( SLua_ErrFunc errfunc, lua_Object table, const char *err_pfx, const char *index, SLuaArgType type, void *dest );
SLua_ErrFunc errfunc
- the error function
lua_Object table
- the table
const char *err_pfx
- a prefix for error messages
const char *index
- the index of the element to delete
SLuaArgType type
- the type of argument to expect (with or'd flags )
Possible values for aSLuaArgType
are as follows:SLua_STRING
,SLua_NUMBER
,SLua_TABLE
,SLua_NIL
,SLua_FUNCTION
,SLua_CFUNCTION
,SLua_USERDATA
,SLua_TYPES
,SLua_OPTIONAL
,SLua_DELENTRY
,SLua_COPY
,SLua_BOGUS
void *dest
- where to store the retrieved data
This function retrieves the value of an element with index
index
in a table. The caller must specify the type of
argument to expect. If the type is or'd with SLua_OPTIONAL
the element need not be present. If the type is SLua_STRING
and is or'd with SLua_COPY
, a copy of the string value is
returned (the caller must handle deallocation).
The value of the element is stored in the passed dest
variable.
Upon error, the passed function errfunc
is called with an
error message. The message will be prefixed with the string in
err_pfx
(using "%s: error message"
). errfunc
may be NULL
, in which case it won't be called.
It returns one of the following values:
0
LUA_NOOBJECT
.
SLua_ENOEL
SLua_ENOENT
SLua_ENOMEM
SLua_STRING|SLua_COPY
and the string could not be
duplicated.
SLua_ENOTYPE
SLua_ENOMATCH
Possible values for a
SLuaError
are as follows:
SLua_ENOERR
,
SLua_ENOENT
,
SLua_ENOMEM
,
SLua_ENOTYPE
,
SLua_ENOEL
,
SLua_ENOMATCH
Diab Jerius