Lua-API++
2015-02-12-3
Lua-API++ library
|
Table object with specialized interface. Similar to Value, it owns a stack slot. More...
Inherits noNew.
Public Member Functions | |
Life cycle | |
Table (const Valref &val) | |
Create a copy of referenced value in owned slot. More... | |
Table (Table &&) | |
It is possible to return Table from functions, but actually moving it is not. | |
Table & | operator= (const Table &)=delete |
Tables cannot be assigned to. | |
Table (Context &context, size_t arrSize=0, size_t recSize=0) noexcept | |
Create a new empty table. More... | |
Table (Temporary src) | |
Take ownership of a temporary value. More... | |
Type conversion | |
operator Valref & () noexcept | |
Reference to owned slot. | |
operator const Valref & () const noexcept | |
Const reference to owned slot. | |
Comparisons (table needs only equality checks). | |
bool | operator== (Valobj rhs) const |
bool | operator!= (Valobj rhs) const |
Miscellaneous | |
Temporary | len () const noexcept |
Length [Lua 5.2+ only]. More... | |
size_t | rawlen () const noexcept |
Raw length [Lua 5.2+ only]. More... | |
size_t | len () const noexcept |
Length [Lua 5.1 only]. | |
Temporary | mt () const noexcept |
Metatable access. More... | |
Iteration | |
template<typename IterationFunction > | |
size_t | iterate (IterationFunction ifunc) const |
Iterate over all table elements. More... | |
Pre-filled table creation | |
template<typename... ValueTypes> | |
Temporary | array (Context &context, ValueType...values) |
Create filled array table. More... | |
template<typename... KeyValueTypes> | |
Temporary | records (Context &context, KeyValueTypes...keyValuePairs) |
Create filled table filled with records. More... | |
Related Functions | |
(Note that these are not member functions.) | |
Comparisons (table needs only equality checks). | |
bool | operator== (Valobj lhs, const Table &rhs) |
bool | operator!= (Valobj lhs, const Table &rhs) |
Indexation | |
RawAccessor | raw |
Accessor for raw reads/writes (skip metatable). More... | |
Temporary | operator[] (Valobj index) const noexcept |
Indexation works as in normal Valref. | |
Table object with specialized interface. Similar to Value, it owns a stack slot.
This class is similar to Value, but it offers interface tailored for table manipulation. Many generic operations are absent while new special methods and members are added.
Create a copy of referenced value in owned slot.
std::runtime_error | if the source is not a table. |
Create a new empty table.
Anonymous tables cannot be used as Lua values.
Take ownership of a temporary value.
std::runtime_error | if the source is not a table. |
|
noexcept |
Length [Lua 5.2+ only].
Same as Valref::len.
|
noexcept |
Raw length [Lua 5.2+ only].
Same as Valref::rawlen.
|
noexcept |
Metatable access.
Same as Valref::mt()
size_t iterate | ( | IterationFunction | ifunc | ) | const |
Iterate over all table elements.
ifunc | Function that processes key-value pairs. Return value tells wheter to continue(true) or break(false) the iteration. |
Create filled array table.
This functions accepts arbitrary number of Valobj values that fill the table under sequential numeric indices starting with 1.
Create filled table filled with records.
This functions accepts arbitrary even number of Valobj values. Each pair is interpreted as key and value. Repeated keys cause overwrite of corresponding value, no error is generated.
RawAccessor raw |
Accessor for raw reads/writes (skip metatable).
This member is indexed with any suitable value just like Valref.