#include <LuaValue.hpp>
Classes | |
| union | PossibleTypes |
This is used just to know the size of the data_ member. More... | |
Public Member Functions | |
| LuaValue () | |
Constructs a LuaValue with a nil value. | |
| LuaValue (bool b) | |
Constructs a LuaValue with boolean type and b value. | |
| LuaValue (float n) | |
Constructs a LuaValue with number type and n value. | |
| LuaValue (double n) | |
Constructs a LuaValue with number type and n value. | |
| LuaValue (long double n) | |
Constructs a LuaValue with number type and n value. | |
| LuaValue (short n) | |
Constructs a LuaValue with number type and n value. | |
| LuaValue (unsigned short n) | |
Constructs a LuaValue with number type and n value. | |
| LuaValue (int n) | |
Constructs a LuaValue with number type and n value. | |
| LuaValue (unsigned n) | |
Constructs a LuaValue with number type and n value. | |
| LuaValue (long n) | |
Constructs a LuaValue with number type and n value. | |
| LuaValue (unsigned long n) | |
Constructs a LuaValue with number type and n value. | |
| LuaValue (const std::string &s) | |
Constructs a LuaValue with string type and s value. | |
| LuaValue (const char *s) | |
Constructs a LuaValue with string type and s value. | |
| LuaValue (const LuaValueMap &t) | |
Constructs a LuaValue with table type and t value. | |
| LuaValue (lua_CFunction f) | |
Constructs a LuaValue with function type and f value. | |
| LuaValue (const LuaFunction &f) | |
Constructs a LuaValue with function type and f value. | |
| LuaValue (const LuaUserData &ud) | |
Constructs a LuaValue with "user data" type and ud value. | |
| LuaValue (const LuaValueList &v) | |
| LuaValue (const LuaValue &other) | |
| Copy constructor. | |
| ~LuaValue () | |
Destroys the LuaValue, freeing all the resources owned by it. | |
| LuaValue & | operator= (const LuaValue &rhs) |
| Assignment operator. | |
| const LuaValueList & | operator= (const LuaValueList &rhs) |
| int | type () const |
| std::string | typeName () const |
| lua_Number | asNumber () const |
| lua_Integer | asInteger () const |
| const std::string & | asString () const |
| bool | asBoolean () const |
| LuaValueMap | asTable () const |
| const LuaFunction & | asFunction () const |
| const LuaUserData & | asUserData () const |
| LuaUserData & | asUserData () |
| template<class T > | |
| T | asObjectPtr () const |
| template<class T > | |
| T | asObjectPtr () |
| bool | operator< (const LuaValue &rhs) const |
| bool | operator> (const LuaValue &rhs) const |
| bool | operator== (const LuaValue &rhs) const |
| bool | operator!= (const LuaValue &rhs) const |
| LuaValue & | operator[] (const LuaValue &key) |
| const LuaValue & | operator[] (const LuaValue &key) const |
Private Member Functions | |
| void | destroyObjectAtData () |
Private Attributes | |
| char | data_ [sizeof(PossibleTypes)] |
| int | dataType_ |
LuaValue is a C++-side thing. There is absolutely no relationship between a LuaValue and a Lua state. This is particularly important for tables and userdata: in Lua, these things are garbage-collectible objects, and variables are just references to them. In Diluculum, a LuaValue represents the value (hence the name!). So, if a LuaValue holds a table, then it contains a collection of keys and values. Similarly, if it holds a userdata, it actually contains a block of memory with some data.
Definition at line 51 of file LuaValue.hpp.
| Diluculum::LuaValue::LuaValue | ( | ) |
Constructs a LuaValue with a nil value.
| Diluculum::LuaValue::LuaValue | ( | bool | b | ) |
Constructs a LuaValue with boolean type and b value.
| Diluculum::LuaValue::LuaValue | ( | float | n | ) |
Constructs a LuaValue with number type and n value.
| Diluculum::LuaValue::LuaValue | ( | double | n | ) |
Constructs a LuaValue with number type and n value.
| Diluculum::LuaValue::LuaValue | ( | long double | n | ) |
Constructs a LuaValue with number type and n value.
| Diluculum::LuaValue::LuaValue | ( | short | n | ) |
Constructs a LuaValue with number type and n value.
| Diluculum::LuaValue::LuaValue | ( | unsigned short | n | ) |
Constructs a LuaValue with number type and n value.
| Diluculum::LuaValue::LuaValue | ( | int | n | ) |
Constructs a LuaValue with number type and n value.
| Diluculum::LuaValue::LuaValue | ( | unsigned | n | ) |
Constructs a LuaValue with number type and n value.
| Diluculum::LuaValue::LuaValue | ( | long | n | ) |
Constructs a LuaValue with number type and n value.
| Diluculum::LuaValue::LuaValue | ( | unsigned long | n | ) |
Constructs a LuaValue with number type and n value.
| Diluculum::LuaValue::LuaValue | ( | const std::string & | s | ) |
Constructs a LuaValue with string type and s value.
| Diluculum::LuaValue::LuaValue | ( | const char * | s | ) |
Constructs a LuaValue with string type and s value.
| Diluculum::LuaValue::LuaValue | ( | const LuaValueMap & | t | ) |
Constructs a LuaValue with table type and t value.
| Diluculum::LuaValue::LuaValue | ( | lua_CFunction | f | ) |
Constructs a LuaValue with function type and f value.
| Diluculum::LuaValue::LuaValue | ( | const LuaFunction & | f | ) |
Constructs a LuaValue with function type and f value.
| Diluculum::LuaValue::LuaValue | ( | const LuaUserData & | ud | ) |
Constructs a LuaValue with "user data" type and ud value.
| Diluculum::LuaValue::LuaValue | ( | const LuaValueList & | v | ) |
| Diluculum::LuaValue::LuaValue | ( | const LuaValue & | other | ) |
Copy constructor.
| Diluculum::LuaValue::~LuaValue | ( | ) | [inline] |
Destroys the LuaValue, freeing all the resources owned by it.
Definition at line 116 of file LuaValue.hpp.
References destroyObjectAtData().
| bool Diluculum::LuaValue::asBoolean | ( | ) | const |
Return the value as a boolean.
| TypeMismatchError | If the value is not a boolean (this is a strict check; no type conversion is performed). |
| const LuaFunction& Diluculum::LuaValue::asFunction | ( | ) | const |
Return the value as a const Lua function.
| TypeMismatchError | If the value is not a Lua function. (this is a strict check; no type conversion is performed). |
| lua_Integer Diluculum::LuaValue::asInteger | ( | ) | const |
Return the value as an integer.
| TypeMismatchError | If the value is not a number (this is a strict check; no type conversion is performed -- no other than the conversion from lua_Number to lua_Integer, that is). |
| lua_Number Diluculum::LuaValue::asNumber | ( | ) | const |
Return the value as a number.
| TypeMismatchError | If the value is not a number (this is a strict check; no type conversion is performed). |
| T Diluculum::LuaValue::asObjectPtr | ( | ) | [inline] |
Assuming that the value stores a C++ object exported to or instantiated in Lua, returns a pointer to the C++ object.
Definition at line 212 of file LuaValue.hpp.
References asUserData(), and Diluculum::LuaUserData::getData().
| T Diluculum::LuaValue::asObjectPtr | ( | ) | const [inline] |
Assuming that the value stores a C++ object exported to or instantiated in Lua, returns a pointer to the (const) C++ object.
Definition at line 202 of file LuaValue.hpp.
References asUserData(), and Diluculum::LuaUserData::getData().
| const std::string& Diluculum::LuaValue::asString | ( | ) | const |
Return the value as a string.
| TypeMismatchError | If the value is not a string (this is a strict check; no type conversion is performed). |
| LuaValueMap Diluculum::LuaValue::asTable | ( | ) | const |
Returns the value as a table (LuaValueMap).
LuaValue. | TypeMismatchError | If the value is not a table (this is a strict check; no type conversion is performed). |
| LuaUserData& Diluculum::LuaValue::asUserData | ( | ) |
Return the value as a (full) user data.
const reference, the LuaUserData::getData() method can be used to get read/write access to the raw user data. | TypeMismatchError | If the value is not a (full) user data (this is a strict check; no type conversion is performed). |
| const LuaUserData& Diluculum::LuaValue::asUserData | ( | ) | const |
Return the value as a const (full) user data.
| TypeMismatchError | If the value is not a (full) user data (this is a strict check; no type conversion is performed). |
Referenced by asObjectPtr().
| void Diluculum::LuaValue::destroyObjectAtData | ( | ) | [private] |
Destroys the object allocated at the data_ member, freeing its resources.
Referenced by ~LuaValue().
| bool Diluculum::LuaValue::operator!= | ( | const LuaValue & | rhs | ) | const [inline] |
"Different" operator for LuaValues.
true if *this and rhs don't have the same value. false otherwise. Definition at line 261 of file LuaValue.hpp.
| bool Diluculum::LuaValue::operator< | ( | const LuaValue & | rhs | ) | const |
"Less than" operator for LuaValues.
LuaValues, but this has to be defined in order to LuaValueMap work nicely. Anyway, here are the rules used to determine who is less than who:typeName() is called for both LuaValues and they are compared with the usual "less than" operator for strings."nil" and "table", then the values contained in the LuaValues are compared using the "less than" operator for that type."nil", the function returns false."table", then the number of elements in each table are compared. The shorter table is "less than" the larger table.false is obviously returned. | const LuaValueList& Diluculum::LuaValue::operator= | ( | const LuaValueList & | rhs | ) |
| bool Diluculum::LuaValue::operator== | ( | const LuaValue & | rhs | ) | const |
"Equal" operator for LuaValues.
true if *this and rhs have the same value. false otherwise. | bool Diluculum::LuaValue::operator> | ( | const LuaValue & | rhs | ) | const |
"Greater than" operator for LuaValues.
operator<.
Returns a const reference to a field of this LuaValue (assuming it is a table). If there is no value associated with the key passed as parameter, returns Nil.
| TypeMismatchError | If this LuaValue does not hold a table. |
Returns a reference to a field of this LuaValue (assuming it is a table). If there is no value associated with the key passed as parameter, inserts a new value (nil) and returns a reference to it.
| TypeMismatchError | If this LuaValue does not hold a table. |
| int Diluculum::LuaValue::type | ( | ) | const [inline] |
Returns one of the LUA_T* constants from lua.h, representing the type stored in this LuaValue.
Definition at line 130 of file LuaValue.hpp.
References dataType_.
| std::string Diluculum::LuaValue::typeName | ( | ) | const |
char Diluculum::LuaValue::data_[sizeof(PossibleTypes)] [private] |
This stores the actual data of this LuaValue.
Implementation details: This member is large enough to store the largest value. The values are allocated here using placement new, with destructors explicitly called whenever necessary.
Definition at line 302 of file LuaValue.hpp.
int Diluculum::LuaValue::dataType_ [private] |
The actual type stored in this LuaValue. The values here are the type constants defined by Lua, like LUA_TNUMBER and LUA_TNIL.
Definition at line 307 of file LuaValue.hpp.
Referenced by type().
1.5.9