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  

Functions  

Static function  

Members detail  

Value()  

Create a lua value object with no associated State

Value(const State &ls, Value::ValueType type)  

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.

Value(const State &ls, Value::Bool n)  

Create a boolean lua value.

Value(const State *ls, Value::Bool n)  

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.

Value(const State &ls, const String &str)  

Create a string lua value.

Value(const State *ls, const String &str)  

Create a string lua value.

Value(const State &ls, const QString &str)  

Create a string lua value.

Value(const State *ls, const QString &str)  

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.

Value(const State &ls, const Ref<UserData> &ud)  

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.

Value(const State *ls, const Ref<UserData> &ud)  

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.

Value(const State &ls, QObject *obj)  

Create a wrapped QObject lua value.

See also QObject wrapping section and Value::Value function.

Value(const State *ls, QObject *obj)  

Create a wrapped QObject lua value.

See also QObject wrapping section and Value::Value function.

Value(const State &ls, const QVariant &qv)  

Create a lua value from a QVariant object.

See also Qt/Lua types conversion section.

Value(const State *ls, const QVariant &qv)  

Create a lua value from a QVariant object.

See also Qt/Lua types conversion section.

Value(State &ls, QObject *obj, bool delete_, bool reparent = true)  

Create a QObject lua value and update associated wrapper ownership flags for this QObject.

See also QObject wrapping section.

template <typename X> Value(const State &ls, const QList<X> &list)  

Create a lua table indexed from 1 with elements from a QList.

See also Qt/Lua types conversion section.

template <typename X> Value(const State &ls, QList<X> &list)  

Create a lua table indexed from 1 with elements from a QList.

See also Qt/Lua types conversion section.

template <typename X> Value(const State &ls, const QVector<X> &vector)  

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, QVector<X> &vector)  

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.

template <typename Key, typename Val> Value(const State &ls, const QHash<Key, Val> &hash)  

Create a lua table with elements from QHash.

See also Qt/Lua types conversion section.

template <typename Key, typename Val> Value(const State &ls, QHash<Key, Val> &hash)  

Create a lua table with elements from QHash.

See also Qt/Lua types conversion section.

template <typename Key, typename Val> Value(const State &ls, const QMap<Key, Val> &map)  

Create a lua table with elements from QMap.

See also Qt/Lua types conversion section.

template <typename Key, typename Val> Value(const State &ls, QMap<Key, Val> &map)  

Create a lua table with elements from QMap.

See also Qt/Lua types conversion section.

Value(const State &ls, const Value &lv)  

Create a lua value copy.

Value(const State *ls, const Value &lv)  

Create a lua value copy.

Value(const Value &lv)  

Create a lua value copy.

virtual ~Value()  

Remove lua value from lua state registry.

enum Bool  

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.

IdentifierValueDescription
False0
True1

enum Operation  

Specify lua operations performed on lua values.

IdentifierDescription
OpAddLua add binary operator +
OpSubLua subtract binary operator -
OpMulLua multiply binary operator *
OpDivLua divied binary operator /
OpModLua modulo binary operator %
OpPowLua power binary operator ^
OpUnmLua negative unary operator -
OpConcatLua concatenation binary operator ..
OpLenLua length unary operator #
OpEqLua equal binary operator ==
OpLtLua less than binary operator <
OpLeLua less than or equal binary operator <=
OpIndexTable index operation
OpNewindexTable newindex operation
OpCallFunction call operation
OpIterateIteration operation
OpAllAll 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

enum ValueType  

Specify lua value types. This is the same as LUA_T* macros defined in lua headers

IdentifierDescription
TNoneNo type
TNilNil value
TBoolBoolean value
TNumberNumber value
TStringString value
TTableLua table value
TFunctionLua function value
TUserDataLua 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.

Value::List call(const Value::List &args) const  

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.

bool is_nil() const  

Check if the value is nil

int len() const  

Return the lua len of tables and strings. Return the result of the Value::OpLen operation on UserData objects or 0 if not supported.

Ref<Iterator> new_iterator() const  

Return an Iterator object suitable to iterate over lua value. This works for lua tables and UserData objects.

operator Bool() const  

Convert a lua value to a boolean. Throw exception if conversion fails.

template <typename Key, typename Val> operator QHash<Key,Val>() const  

Create a QHash with elements from lua table.

See also Qt/Lua types conversion section.

template <typename X> operator QList<X>() 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> operator QMap<Key,Val>() const  

Create a QMap with elements from lua table.

See also Qt/Lua types conversion section.

operator QString() const  

Convert a lua string value to a String object. Throw exception if conversion fails.

operator QVariant() const  

Convert a lua value to a QVariant.

See also Qt/Lua types conversion section.

template <typename X> operator QVector<X>() const  

Create a QVector with elements from lua table. Table keys are searched from 1.

See also Qt/Lua types conversion section.

template <typename X> operator Ref<X>() const  

See Value::to_userdata_cast function.

operator String() const  

Convert a lua string value to a String object. Throw exception if conversion fails.

operator double() const  

Convert a lua number value to a double. Throw exception if conversion fails.

operator float() const  

Convert a lua number value to a double. Throw exception if conversion fails.

operator int() const  

Convert a lua number value to an integer. Throw exception if conversion fails.

operator unsigned int() const  

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.

Value::List operator()(const Value &arg1) const  

Call operation on a lua userdata or lua function value.

Value::List operator()(const Value &arg1, const Value &arg2) const  

Call operation on a lua userdata or lua function value.

Value::List operator()(const Value &arg1, const Value &arg2, const Value &arg3) 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  

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.

Value & operator=(const Value &lv)  

Copy a lua value.

Value & operator=(Value::Bool n)  

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.

Value & operator=(const String &str)  

Assign a string to lua value.

Value & operator=(const QString &str)  

Assign a string to lua value.

Value & operator=(const char *str)  

Assign a string to lua value.

Value & operator=(const Ref<UserData> &ud)  

Assign a userdata to lua value.

Value & operator=(QObject *obj)  

Assign a QObject to lua value.

See also QObject wrapping section.

Value & operator=(const QVariant &qv)  

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.

bool operator==(const char *str) const  

Compare lua values with given C string.

bool operator==(double n) const  

Compare lua values with given number.

Value operator[](const Value &key) const  

Index operation on a lua userdata or lua table value.

Value operator[](const String &key) const  

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.

ValueRef operator[](const Value &key)  

Index operation on a lua userdata or lua table value.

ValueRef operator[](const String &key)  

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

const char * to_cstring() const  

Convert a lua string value to a C string. Throw exception if conversion fails.

int to_integer() const  

Convert a lua number value to an integer. Throw exception if conversion fails.

double to_number() const  

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.

template <typename X> X * to_qobject_cast() const  

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.

Ref<UserData> to_userdata() const  

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.

Ref<UserData> to_userdata_null() const  

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.

static String type_name(Value::ValueType t)  

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.

Valid XHTML 1.0 StrictGenerated by diaxen on Sun Jan 8 22:46:02 2012 using MkDoc