Lua-API++
2015-02-12-3
Lua-API++ library
|
Non-owning reference to Lua value. More...
Public Member Functions | |
Life cycle | |
Valref (const Valref &) noexcept=default | |
Copy constructor. More... | |
template<typename ValueType > | |
Valref & | operator= (ValueType &&val) |
Assignment. More... | |
Type info and conversion | |
template<typename T > | |
T | cast () const |
Explicit checked conversion to supported types. More... | |
template<typename T > | |
T | optcast (const T &backupValue=T()) const noexcept |
Safe conversion to supported types [Lua 5.2- only]. More... | |
template<typename T > | |
T | to () const noexcept |
Unchecked conversion to supported types. More... | |
template<typename T > | |
T | to (const T &backupValue) const noexcept |
Safe conversion to supported types. More... | |
operator bool () const | |
operator int () const | |
operator unsigned int () const | |
operator long long () const | |
operator unsigned long long () const | |
operator float () const | |
operator double () const | |
operator CFunction () const | |
operator LightUserData () const | |
operator const char * () const | |
operator std::string () const | |
template<typename T > | |
bool | is () const noexcept |
Check if the value convertible to given type. More... | |
bool | isInteger () const noexcept |
Check if the value is an integer number [Lua 5.3+ only] More... | |
ValueType | type () const noexcept |
Actual type of referenced value. | |
Comparisons (made through Lua) | |
bool | operator== (Valobj &&rhs) const |
bool | operator!= (Valobj &&rhs) const |
bool | operator< (Valobj &&rhs) const |
bool | operator> (Valobj &&rhs) const |
bool | operator<= (Valobj &&rhs) const |
bool | operator>= (Valobj &&rhs) const |
Indexation | |
Temporary | operator[] (Valobj &&index_) const noexcept |
Indexation. | |
Function calls | |
template<typename... Args> | |
Temporary | operator() (Args &&...args) const noexcept |
Natural call form. More... | |
template<typename... Args> | |
Temporary | call (Args &&...args) const noexcept |
Call method. More... | |
template<typename... Args> | |
Temporary | pcall (Args &&...args) const noexcept |
Protected call method. More... | |
Closure handling | |
Temporary | upvalue (size_t index) const noexcept |
Upvalue access inside closures. More... | |
Valset | getUpvalues () const noexcept |
Retrieve upvalues and their names. More... | |
ClosureInfo | getClosureInfo () const noexcept |
Retrieve information about closure [Lua 5.2+ only]. More... | |
size_t | getClosureInfo () const noexcept |
Retrieve information about closure [Lua 5.1 only]. More... | |
Miscellaneous operations | |
Temporary | len () const noexcept |
Length [Lua 5.2+ only]. | |
size_t | rawlen () const noexcept |
Raw length (no metamethods) [Lua 5.2+ only]. | |
size_t | len () const noexcept |
Length [Lua 5.1 only]. | |
Temporary | mt () const noexcept |
Metatable. More... | |
Temporary | linked () const noexcept |
Linked value [Lua 5.3+ only]. More... | |
Related Functions | |
(Note that these are not member functions.) | |
Comparisons (made through Lua) | |
bool | operator== (Valobj &&lhs, const Valref &rhs) |
bool | operator!= (Valobj &&lhs, const Valref &rhs) |
bool | operator< (Valobj &&lhs, const Valref &rhs) |
bool | operator> (Valobj &&lhs, const Valref &rhs) |
bool | operator<= (Valobj &&lhs, const Valref &rhs) |
bool | operator>= (Valobj &&lhs, const Valref &rhs) |
Concatenation | |
Temporary | operator& (Valobj &&lhs, Valobj &&rhs) const noexcept |
Concatenation. More... | |
Arithmetics (Lua 5.2+ only). | |
Temporary | operator- (Valobj &&lhs) |
[Lua 5.2+ only] More... | |
Temporary | operator+ (Valobj &&lhs, const Valobj &rhs) noexcept |
[Lua 5.2+ only] More... | |
Temporary | operator- (Valobj &&lhs, const Valobj &rhs) noexcept |
[Lua 5.2+ only] More... | |
Temporary | operator* (Valobj &&lhs, const Valobj &rhs) noexcept |
[Lua 5.2+ only] More... | |
Temporary | operator/ (Valobj &&lhs, const Valobj &rhs) noexcept |
[Lua 5.2+ only] More... | |
Temporary | operator% (Valobj &&lhs, const Valobj &rhs) noexcept |
[Lua 5.2+ only] More... | |
Temporary | operator^ (Valobj &&lhs, const Valobj &rhs) noexcept |
Power [Lua 5.2+ only]. More... | |
Temporary | idiv (Valobj &&lhs, Valobj &&rhs) |
Integer division [Lua 5.3+ only]. More... | |
Binary operations (Lua 5.3+ only) | |
Temporary | band (Valobj &&lhs, Valobj &&rhs) |
Bitwise AND [Lua 5.3+ only]. More... | |
Temporary | bor (Valobj &&lhs, Valobj &&rhs) |
Bitwise OR [Lua 5.3+ only]. More... | |
Temporary | bxor (Valobj &&lhs, Valobj &&rhs) |
Bitwise XOR [Lua 5.3+ only]. More... | |
Temporary | bneg (Valobj &&lhs) |
Bitwise NOT [Lua 5.3+ only]. More... | |
Temporary | shl (Valobj &&lhs, Valobj &&rhs) |
Bit shift left [Lua 5.3+ only]. More... | |
Temporary | shr (Valobj &&lhs, Valobj &&rhs) |
Bit shift right [Lua 5.3+ only]. More... | |
Non-owning reference to Lua value.
This is a reference to a specific slot on Lua stack. The operations with Lua value inside that slot are performed through this object.
Copy constructor.
Copies of Valref point to the same stack slot. Be careful with copying Valref objects just as you would be with normal references. This copy constructor is enabled so it is possible to pass references as function arguments.
Assignment.
Lua values, supported native types or registered userdata can be assigned to a referenced stack slot.
T cast | ( | ) | const |
Explicit checked conversion to supported types.
Call this function with type to be converted to.
std::runtime_error | if the value type is incompatible. |
T | the type to cast to, one of those:
|
|
noexcept |
Safe conversion to supported types [Lua 5.2- only].
T | the type to cast to. Converts to all types supported by cast except user data. |
|
noexcept |
Unchecked conversion to supported types.
T | the type to cast to. Converts to all types supported by cast including user data. |
|
noexcept |
Safe conversion to supported types.
T | the type to cast to. Converts to all types supported by cast except user data. |
operator bool | ( | ) | const |
Never fails.
operator int | ( | ) | const |
std::runtime_error | if the value type is incompatible. |
operator unsigned int | ( | ) | const |
std::runtime_error | if the value type is incompatible. |
operator long long | ( | ) | const |
std::runtime_error | if the value type is incompatible. |
operator unsigned long long | ( | ) | const |
std::runtime_error | if the value type is incompatible. |
operator float | ( | ) | const |
std::runtime_error | if the value type is incompatible. |
operator double | ( | ) | const |
std::runtime_error | if the value type is incompatible. |
operator CFunction | ( | ) | const |
std::runtime_error | if the value type is incompatible. |
operator LightUserData | ( | ) | const |
std::runtime_error | if the value type is incompatible. |
operator const char * | ( | ) | const |
std::runtime_error | if the value type is incompatible. |
|
inline |
std::runtime_error | if the value type is incompatible. |
|
noexcept |
Check if the value convertible to given type.
Exception: is<bool> checks if value type is actually boolean, because any value can be converted to bool.
T | the type to check compatibility with, one of those:
|
|
noexcept |
Check if the value is an integer number [Lua 5.3+ only]
|
noexcept |
|
noexcept |
|
noexcept |
Protected call method.
Any suitable value is accepted as an argument.
|
noexcept |
Upvalue access inside closures.
You can read and write upvalues inside closures with this function.
index | 1-based index of accessed upvalue. |
std::runtime_error | on wrong index. |
|
noexcept |
Retrieve upvalues and their names.
This function returns values and names of all closure upvalues. Upvalues are always named "" in C closures. Upvalue ordering in Lua functions is undefined.
|
noexcept |
Retrieve information about closure [Lua 5.2+ only].
This function is applicable only to closures. It returns number of upvalues, parameters and whether function is variadic (accepts variable number of arguments).
nParameters
is always 0 and variadic
is always true
.
|
noexcept |
Retrieve information about closure [Lua 5.1 only].
This function is applicable only to closures.
|
noexcept |
Concatenation.
Power [Lua 5.2+ only].