Lua_icxx  1.02 (Aug 2011)
LuaObjRef Class Reference

Represent a reference to a Lua object. More...

#include <LuaObjRef.h>

Inheritance diagram for LuaObjRef:

List of all members.

Public Types

enum  MetaMethod {
  MM_ADD,
  MM_MULTIPLY,
  MM_SUBTRACT,
  MM_DIVIDE,
  MM_UNARY_MINUS,
  MM_NEGATE,
  MM_CONCATENATE,
  MM_EQUAL,
  MM_LESS_THAN,
  MM_LESS_OR_EQUAL,
  MM_TOSTRING,
  MM_INDEX,
  MM_FIELD,
  MM_NEW_INDEX,
  MM_NEW_FIELD
}
 Enumeration of all the possible metamethods of a Lua object. More...

Public Member Functions

 LuaObjRef (const std::string &id="nil")
 reference to Lua nil
void setNil ()
 Set this reference to point to Lua nil.
bool isNil () const
 Test if this reference points to a Lua nil.
int getTypeID () const
 Get the Lua type identifier (one of the LUA_T variables)
std::string typeName () const
 Get the Lua type name.
bool isError () const
 Get error status associated with the Lua operation that got this ObjRef.
std::string getErrMsg () const
 Get error message associated with the Lua op that got this objRef.
void setID (const std::string &id)
 Give this reference a "name". Useful for log output etc.
const std::string & getID () const
 Get the name given to this reference. Returns "" if none given.
bool setMetaProtected (bool val=true)
 Lock/Unlock this object's metatable from being changed by Lua scripts.
bool hasMetaTable () const
 Returns true if currently has a metatable, false otherwise.
void setMetaTable (const LuaTableRef &)
 Replace this object's metatable with given table.
LuaTempResult getMetaTable () const
 Gets this object's metatable (or nil if there is none)
void setMetaBase (const LuaTableRef &)
 Set which table to inherit from.
bool hasMetaBase () const
 True only if this object has a metatable with an __index entry.
void setMetaMethod (MetaMethod id, const LuaFuncRef &func)
 set this.metatable[method]=func; method determined by id
void pushObj () const
 Push the object onto the Lua stack.
lua_State * getLuaState () const
 Get the Lua state in which this object exists.
 LuaObjRef (const LuaTempResult &)
 Reference a Lua object on the stack.
 LuaObjRef (const LuaTempResult::Item &)
 Reference a Lua object on the stack.
 LuaObjRef (lua_State *, int stackPos)
 Reference a Lua object on the stack.
void resetRef (const LuaTempResult &result)
 Change what this object reference points to.
void resetRef (const LuaTempResult::Item &)
 Change what this object reference points to.
LuaObjRefoperator= (const LuaTempResult &result)
 Change what this object reference points to.
LuaObjRefoperator= (const LuaTempResult::Item &resultItem)
 Change what this object reference points to.
template<typename TT >
 operator TT () const
 convert this Lua object to a TT value
template<typename TT >
TT getAs () const
 convert this Lua object to a TT value
template<typename TT >
bool operator== (TT val) const
 Compare this Lua object to a value.
template<typename TT >
bool operator!= (TT val) const
 Compare this Lua object to a value.
template<typename TT >
bool operator>= (TT val) const
 Compare this Lua object to a value.
template<typename TT >
bool operator<= (TT val) const
 Compare this Lua object to a value.
template<typename TT >
bool operator> (TT val) const
 Compare this Lua object to a value.
template<typename TT >
bool operator< (TT val) const
 Compare this Lua object to a value.

Protected Attributes

lua_State * mLua
 lua state, for use by derived classes

Detailed Description

Represent a reference to a Lua object.

This can be any object: function, table, number, string, coroutine, user data, etc.

Todo:
: add the constructor, operator= and resetRef taking 1 arg: const LuaObjRef& rhs

Definition at line 28 of file LuaObjRef.h.


Member Enumeration Documentation

Enumeration of all the possible metamethods of a Lua object.

Enumerator:
MM_ADD 

a+b

MM_MULTIPLY 

a*b

MM_SUBTRACT 

a-b

MM_DIVIDE 

a/b

MM_UNARY_MINUS 

-a

MM_NEGATE 

synonym for -a

MM_CONCATENATE 

a..b

MM_EQUAL 

a==b

MM_LESS_THAN 

a<b

MM_LESS_OR_EQUAL 

a<=b

MM_TOSTRING 

`a`

MM_INDEX 

get a[]

MM_FIELD 

synonym for get a[]

MM_NEW_INDEX 

set a[]

MM_NEW_FIELD 

synonym for set a[]

Definition at line 104 of file LuaObjRef.h.