Value class reference
[Base module]
Declaration
#include <QtLua/Value>
namespace QtLua {
class Value;
};
This class is a member of the QtLua namespace.
Description
This class exposes a lua value to C++ code. It provides conversion functions, cast operators, access operators and standard C++ iterators.
Each Value object store its associated lua value in the lua interpreter state registry table.
See also Qt/Lua types conversion section, Iterator class, Value::iterator struct and Value::const_iterator struct.
Members
Types
- enum Bool
- struct List
- enum Operation
- typedef [...] Operations
- enum ValueType
- struct const_iterator
- struct iterator
Functions
- Value()
- Value(const State &ls, Value::ValueType type)
- Value(const State &ls)
- Value(const State *ls)
- Value(const State &ls, Value::Bool n)
- Value(const State *ls, Value::Bool n)
- Value(const State &ls, float n)
- Value(const State *ls, float n)
- Value(const State &ls, double n)
- Value(const State *ls, double n)
- Value(const State &ls, int n)
- Value(const State *ls, int n)
- Value(const State &ls, unsigned int n)
- Value(const State *ls, unsigned int n)
- Value(const State &ls, const String &str)
- Value(const State *ls, const String &str)
- Value(const State &ls, const QString &str)
- Value(const State *ls, const QString &str)
- Value(const State &ls, const char *str)
- Value(const State *ls, const char *str)
- Value(const State &ls, const Ref<UserData> &ud)
- Value(const State *ls, const Ref<UserData> &ud)
- Value(const State &ls, QObject *obj)
- Value(const State *ls, QObject *obj)
- Value(const State &ls, const QVariant &qv)
- Value(const State *ls, const QVariant &qv)
- Value(State &ls, QObject *obj, bool delete_, bool reparent = [...])
- template Value(const State &ls, const QList<X> &list)
- template Value(const State &ls, QList<X> &list)
- template Value(const State &ls, const QVector<X> &vector)
- template Value(const State &ls, QVector<X> &vector)
- template Value(const State &ls, unsigned int size, const X *array)
- template Value(const State &ls, const QHash<Key, Val> &hash)
- template Value(const State &ls, QHash<Key, Val> &hash)
- template Value(const State &ls, const QMap<Key, Val> &map)
- template Value(const State &ls, QMap<Key, Val> &map)
- Value(const State &ls, const Value &lv)
- Value(const State *ls, const Value &lv)
- Value(const Value &lv)
- virtual ~Value()
- Value::iterator begin()
- Value::const_iterator begin() const
- Value::List call(const Value::List &args) const
- bool connect(QObject *obj, const char *signal)
- bool disconnect(QObject *obj, const char *signal)
- Value::iterator end()
- Value::const_iterator end() const
- State * get_state() const
- bool is_nil() const
- int len() const
- Ref<Iterator> new_iterator() const
- operator Bool() const
- template operator QHash<Key,Val>() const
- template operator QList<X>() const
- template operator QMap<Key,Val>() const
- operator QString() const
- operator QVariant() const
- template operator QVector<X>() const
- template operator Ref<X>() const
- operator String() const
- operator double() const
- operator float() const
- operator int() const
- operator unsigned int() const
- Value::List operator()() const
- Value::List operator()(const Value &arg1) const
- Value::List operator()(const Value &arg1, const Value &arg2) const
- Value::List operator()(const Value &arg1, const Value &arg2, const Value &arg3) const
- Value::List operator()(const Value &arg1, const Value &arg2, const Value &arg3, const Value &arg4) const
- Value::List operator()(const Value &arg1, const Value &arg2, const Value &arg3, const Value &arg4, const Value &arg5) const
- Value::List operator()(const Value &arg1, const Value &arg2, const Value &arg3, const Value &arg4, const Value &arg5, const Value &arg6) const
- bool operator<(const Value &lv) const
- Value & operator=(const Value &lv)
- Value & operator=(Value::Bool n)
- Value & operator=(double n)
- Value & operator=(float n)
- Value & operator=(int n)
- Value & operator=(unsigned int n)
- Value & operator=(const String &str)
- Value & operator=(const QString &str)
- Value & operator=(const char *str)
- Value & operator=(const Ref<UserData> &ud)
- Value & operator=(QObject *obj)
- Value & operator=(const QVariant &qv)
- bool operator==(const Value &lv) const
- bool operator==(const String &str) const
- bool operator==(const char *str) const
- bool operator==(double n) const
- Value operator[](const Value &key) const
- Value operator[](const String &key) const
- Value operator[](const char *key) const
- Value operator[](double key) const
- Value operator[](int key) const
- Value operator[](unsigned int key) const
- ValueRef operator[](const Value &key)
- ValueRef operator[](const String &key)
- ValueRef operator[](const char *key)
- ValueRef operator[](double key)
- ValueRef operator[](int key)
- ValueRef operator[](unsigned int key)
- bool support(Value::Operation c) const
- Value::Bool to_boolean() const
- QByteArray to_bytecode() const
- const char * to_cstring() const
- int to_integer() const
- double to_number() const
- template QHash<Key, Val> to_qhash() const
- template QList<X> to_qlist() const
- template QMap<Key, Val> to_qmap() const
- QObject * to_qobject() const
- template X * to_qobject_cast() const
- QString to_qstring() const
- QVariant to_qvariant() const
- template QVector<X> to_qvector() const
- String to_string() const
- String to_string_p(bool quote_string = [...]) const
- Ref<UserData> to_userdata() const
- template Ref<X> to_userdata_cast() const
- Ref<UserData> to_userdata_null() const
- Value::ValueType type() const
- String type_name() const
- String type_name_u() const
Static function
- static String type_name(Value::ValueType t)
Members detail
Create a lua value object with no associated State
Create a default value of the given type. Useful to create empty lua tables.
Value(const State &ls)
Create a "nil" lua value.
Value(const State *ls)
Create a "nil" lua value.
Create a boolean lua value.
Create a boolean lua value.
Value(const State &ls, float n)
Create a number lua value.
Value(const State *ls, float n)
Create a number lua value.
Value(const State &ls, double n)
Create a number lua value.
Value(const State *ls, double n)
Create a number lua value.
Value(const State &ls, int n)
Create a number lua value.
Value(const State *ls, int n)
Create a number lua value.
Value(const State &ls, unsigned int n)
Create a number lua value.
Value(const State *ls, unsigned int n)
Create a number lua value.
Create a string lua value.
Create a string lua value.
Create a string lua value.
Create a string lua value.
Value(const State &ls, const char *str)
Create a string lua value.
Value(const State *ls, const char *str)
Create a string lua value.
Create a lua userdata value. The value will hold a Ref reference to the UserData object which will be dropped later by the lua garbage collector.
Create a lua userdata value. The value will hold a Ref reference to the UserData object which will be dropped later by the lua garbage collector.
Create a wrapped QObject lua value.
See also QObject wrapping section and Value::Value function.
Create a wrapped QObject lua value.
See also QObject wrapping section and Value::Value function.
Create a lua value from a QVariant object.
See also Qt/Lua types conversion section.
Create a lua value from a QVariant object.
See also Qt/Lua types conversion section.
Create a QObject lua value and update associated wrapper ownership flags for this QObject.
See also QObject wrapping section.
Create a lua table indexed from 1 with elements from a QList.
See also Qt/Lua types conversion section.
Create a lua table indexed from 1 with elements from a QList.
See also Qt/Lua types conversion section.
Create a lua table indexed from 1 with elements from a QVector.
See also Qt/Lua types conversion section.
Create a lua table indexed from 1 with elements from a QVector.
See also Qt/Lua types conversion section.
template <typename X> Value(const State &ls, unsigned int size, const X *array)
Create a lua table indexed from 1 with elements from a C array.
See also Qt/Lua types conversion section.
Create a lua table with elements from QHash.
See also Qt/Lua types conversion section.
Create a lua table with elements from QHash.
See also Qt/Lua types conversion section.
Create a lua table with elements from QMap.
See also Qt/Lua types conversion section.
Create a lua table with elements from QMap.
See also Qt/Lua types conversion section.
Create a lua value copy.
Create a lua value copy.
Value(const Value &lv)
Create a lua value copy.
Remove lua value from lua state registry.
Boolean type used for Value constructor.
The native C++ bool type is not used here due to implicit cast between bool and pointers which prevent proper constructor overloading.
Identifier | Value | Description |
---|---|---|
False | 0 | |
True | 1 |
Specify lua operations performed on lua values.
Identifier | Description |
---|---|
OpAdd | Lua add binary operator + |
OpSub | Lua subtract binary operator - |
OpMul | Lua multiply binary operator * |
OpDiv | Lua divied binary operator / |
OpMod | Lua modulo binary operator % |
OpPow | Lua power binary operator ^ |
OpUnm | Lua negative unary operator - |
OpConcat | Lua concatenation binary operator .. |
OpLen | Lua length unary operator # |
OpEq | Lua equal binary operator == |
OpLt | Lua less than binary operator < |
OpLe | Lua less than or equal binary operator <= |
OpIndex | Table index operation |
OpNewindex | Table newindex operation |
OpCall | Function call operation |
OpIterate | Iteration operation |
OpAll | All operations mask |
See also Value::support function, UserData::meta_operation function, UserData::support function and Value::Operations typedef.
typedef Value::Operation Operations
No documentation available
Specify lua value types. This is the same as LUA_T* macros defined in lua headers
Identifier | Description |
---|---|
TNone | No type |
TNil | Nil value |
TBool | Boolean value |
TNumber | Number value |
TString | String value |
TTable | Lua table value |
TFunction | Lua function value |
TUserData | Lua userdata value |
Value::iterator begin()
Get an Value::iterator to traverse a lua userdata or lua table value.
Value::const_iterator begin() const
Get a Value::const_iterator to traverse a lua userdata or lua table value.
Call operation on a lua userdata or lua function value.
bool connect(QObject *obj, const char *signal)
Connect a QObject signal to a lua value. The value will be called when the signal is emited.
See also Value::disconnect function, QObject::connect and QObject wrapping section.
bool disconnect(QObject *obj, const char *signal)
Disconnect a QObject signal from a lua value.
See also Value::connect function, QObject::disconnect and QObject wrapping section.
Value::iterator end()
Get an Value::iterator to traverse a lua userdata or lua table value.
Value::const_iterator end() const
Get a Value::const_iterator to traverse a lua userdata or lua table value.
State * get_state() const
Get associated lua state.
Check if the value is nil
Return the lua len of tables and strings. Return the result of the Value::OpLen operation on UserData objects or 0 if not supported.
Return an Iterator object suitable to iterate over lua value. This works for lua tables and UserData objects.
Convert a lua value to a boolean. Throw exception if conversion fails.
Create a QHash with elements from lua table.
See also Qt/Lua types conversion section.
Create a QList with elements from lua table. Table keys are searched from 1.
See also Qt/Lua types conversion section.
Create a QMap with elements from lua table.
See also Qt/Lua types conversion section.
Convert a lua string value to a String object. Throw exception if conversion fails.
Convert a lua value to a QVariant.
See also Qt/Lua types conversion section.
Create a QVector with elements from lua table. Table keys are searched from 1.
See also Qt/Lua types conversion section.
See Value::to_userdata_cast function.
Convert a lua string value to a String object. Throw exception if conversion fails.
Convert a lua number value to a double. Throw exception if conversion fails.
Convert a lua number value to a double. Throw exception if conversion fails.
Convert a lua number value to an integer. Throw exception if conversion fails.
Convert a lua number value to an integer. Throw exception if conversion fails.
Value::List operator()() const
Call operation on a lua userdata or lua function value.
Call operation on a lua userdata or lua function value.
Call operation on a lua userdata or lua function value.
Call operation on a lua userdata or lua function value.
Value::List operator()(const Value &arg1, const Value &arg2, const Value &arg3, const Value &arg4) const
Call operation on a lua userdata or lua function value.
Value::List operator()(const Value &arg1, const Value &arg2, const Value &arg3, const Value &arg4, const Value &arg5) const
Call operation on a lua userdata or lua function value.
Value::List operator()(const Value &arg1, const Value &arg2, const Value &arg3, const Value &arg4, const Value &arg5, const Value &arg6) const
Call operation on a lua userdata or lua function value.
bool operator<(const Value &lv) const
Compare lua values.
Copy a lua value.
Assign a boolean to lua value.
Value & operator=(double n)
Assign a number to lua value.
Value & operator=(float n)
Assign a number to lua value.
Value & operator=(int n)
Assign a number to lua value.
Value & operator=(unsigned int n)
Assign a number to lua value.
Assign a string to lua value.
Assign a string to lua value.
Value & operator=(const char *str)
Assign a string to lua value.
Assign a userdata to lua value.
Assign a QObject to lua value.
See also QObject wrapping section.
Convert a QVariant to lua value.
See also Qt/Lua types conversion section.
bool operator==(const Value &lv) const
Compare lua values.
bool operator==(const String &str) const
Compare lua values with given string.
Compare lua values with given C string.
Compare lua values with given number.
Index operation on a lua userdata or lua table value.
Index operation on a lua userdata or lua table value.
Value operator[](const char *key) const
Index operation on a lua userdata or lua table value.
Value operator[](double key) const
Index operation on a lua userdata or lua table value.
Value operator[](int key) const
Index operation on a lua userdata or lua table value.
Value operator[](unsigned int key) const
Index operation on a lua userdata or lua table value.
Index operation on a lua userdata or lua table value.
Index operation on a lua userdata or lua table value.
ValueRef operator[](const char *key)
Index operation on a lua userdata or lua table value.
ValueRef operator[](double key)
Index operation on a lua userdata or lua table value.
ValueRef operator[](int key)
Index operation on a lua userdata or lua table value.
ValueRef operator[](unsigned int key)
Index operation on a lua userdata or lua table value.
bool support(Value::Operation c) const
Check given operation support.
See also UserData::support function.
Value::Bool to_boolean() const
Convert a lua value to a boolean. Throw exception if conversion fails.
QByteArray to_bytecode() const
Dump the bytecode for a function object
Convert a lua string value to a C string. Throw exception if conversion fails.
Convert a lua number value to an integer. Throw exception if conversion fails.
Convert a lua number value to a double. Throw exception if conversion fails.
template <typename Key, typename Val> QHash<Key, Val> to_qhash() const
Create a QHash with elements from lua table.
See also Qt/Lua types conversion section.
template <typename X> QList<X> to_qlist() const
Create a QList with elements from lua table. Table keys are searched from 1.
See also Qt/Lua types conversion section.
template <typename Key, typename Val> QMap<Key, Val> to_qmap() const
Create a QMap with elements from lua table.
See also Qt/Lua types conversion section.
QObject * to_qobject() const
Convert a lua value to a QObject pointer. Throw exception if conversion or cast fails.
See also Value::to_qobject_cast function.
Convert a lua value to a QObject subclass pointer. Subclass must have the Q_OBJECT macro in it's definition. Throw exception if conversion or cast fails.
See also Value::to_qobject function.
QString to_qstring() const
Convert a lua string value to a String object. Throw exception if conversion fails.
QVariant to_qvariant() const
Convert a lua value to a QVariant.
See also Qt/Lua types conversion section.
template <typename X> QVector<X> to_qvector() const
Create a QVector with elements from lua table. Table keys are searched from 1.
See also Qt/Lua types conversion section.
String to_string() const
Convert a lua string value to a String object. Throw exception if conversion fails.
String to_string_p(bool quote_string = true) const
Convert any type to a string representation suitable for pretty printing. Never throw.
Convert a lua value to a Ref pointer to an UserData. Throw exception if conversion fails.
See also Value::to_userdata_null function and Value::to_userdata_cast function.
template <typename X> Ref<X> to_userdata_cast() const
Convert a lua value to a Ref pointer to an UserData and dynamic cast to given Ref pointer to requested type. Throw exception if conversion or cast fails.
See also Value::to_userdata function and Value::to_userdata_cast function.
Convert a lua value to a Ref pointer to an UserData.
The return value is a null Ref if conversion fails.
See also Value::to_userdata function and Value::to_userdata_cast function.
Value::ValueType type() const
Get lua value type.
String type_name() const
Get value raw lua type name.
Get value raw lua type name.
String type_name_u() const
Get value type name, if the value is a UserData, the type name is extracted using the UserData::get_type_name function.