sqrat  0.9
sqrat
 All Classes Functions Variables Enumerations Enumerator Pages
Public Member Functions | List of all members
Sqrat::TableBase Class Reference

The base class for Table that implements almost all of its functionality. More...

#include <sqratTable.h>

Inheritance diagram for Sqrat::TableBase:
Sqrat::Object Sqrat::RegistryTable Sqrat::RootTable Sqrat::Table

Public Member Functions

 TableBase (HSQUIRRELVM v=DefaultVM::Get())
 
 TableBase (const Object &obj)
 
 TableBase (HSQOBJECT o, HSQUIRRELVM v=DefaultVM::Get())
 
void Bind (const SQChar *name, Object &obj)
 
TableBaseSquirrelFunc (const SQChar *name, SQFUNCTION func)
 
template<class V >
TableBaseSetValue (const SQChar *name, const V &val)
 
template<class V >
TableBaseSetValue (const SQInteger index, const V &val)
 
template<class V >
TableBaseSetInstance (const SQChar *name, V *val)
 
template<class V >
TableBaseSetInstance (const SQInteger index, V *val)
 
template<class F >
TableBaseFunc (const SQChar *name, F method)
 
template<class F >
TableBaseOverload (const SQChar *name, F method)
 
template<typename T >
SharedPtr< T > GetValue (const SQChar *name)
 
template<typename T >
SharedPtr< T > GetValue (int index)
 
Function GetFunction (const SQChar *name)
 
Function GetFunction (const SQInteger index)
 
- Public Member Functions inherited from Sqrat::Object
 Object ()
 
 Object (const Object &so)
 
 Object (HSQOBJECT o, HSQUIRRELVM v=DefaultVM::Get())
 
template<class T >
 Object (T *instance, HSQUIRRELVM v=DefaultVM::Get())
 
virtual ~Object ()
 
Objectoperator= (const Object &so)
 
HSQUIRRELVM & GetVM ()
 
HSQUIRRELVM GetVM () const
 
SQObjectType GetType () const
 
bool IsNull () const
 
virtual HSQOBJECT GetObject () const
 
virtual HSQOBJECT & GetObject ()
 
 operator HSQOBJECT & ()
 
void Release ()
 
Object GetSlot (const SQChar *slot) const
 
Object GetSlot (SQInteger index) const
 
template<class T >
Cast () const
 
template<class T >
Object operator[] (T slot)
 
SQInteger GetSize () const
 
bool Next (iterator &iter) const
 

Detailed Description

The base class for Table that implements almost all of its functionality.

Constructor & Destructor Documentation

Sqrat::TableBase::TableBase ( HSQUIRRELVM  v = DefaultVM::Get())
inline

Default constructor (null)

Parameters
vVM that the table will exist in
Sqrat::TableBase::TableBase ( const Object obj)
inline

Construct the TableBase from an Object that already exists

Parameters
objAn Object that should already represent a Squirrel table
Sqrat::TableBase::TableBase ( HSQOBJECT  o,
HSQUIRRELVM  v = DefaultVM::Get() 
)
inline

Construct the TableBase from a HSQOBJECT and HSQUIRRELVM that already exist

Parameters
oSquirrel object that should already represent a Squirrel table
vSquirrel VM that contains the Squirrel object given

Member Function Documentation

void Sqrat::TableBase::Bind ( const SQChar *  name,
Object obj 
)
inline

Binds a Table or Class to the Table (can be used to facilitate namespaces)

Parameters
nameThe key in the table being assigned a Table or Class
objTable or Class that is being placed in the table
Remarks
Bind cannot be called "inline" like other functions because it introduces order-of-initialization bugs.
template<class F >
TableBase& Sqrat::TableBase::Func ( const SQChar *  name,
method 
)
inline

Sets a key in the Table to a specific function

Parameters
nameThe key in the table being assigned a value
methodFunction that is being placed in the Table
Template Parameters
FType of function (only define this if you need to choose a certain template specialization or overload)
Returns
The Table itself so the call can be chained
Function Sqrat::TableBase::GetFunction ( const SQChar *  name)
inline

Gets a Function from a key in the Table

Parameters
nameThe key in the table that contains the Function
Returns
Function found in the Table (null if failed)
Function Sqrat::TableBase::GetFunction ( const SQInteger  index)
inline

Gets a Function from an index in the Table

Parameters
indexThe index in the table that contains the Function
Returns
Function found in the Table (null if failed)
template<typename T >
SharedPtr<T> Sqrat::TableBase::GetValue ( const SQChar *  name)
inline

Returns the value at a given key

Parameters
nameKey of the element
Template Parameters
TType of value (fails if value is not of this type)
Returns
SharedPtr containing the value (or null if failed)
Remarks
This function MUST have its Error handled if it occurred.
template<typename T >
SharedPtr<T> Sqrat::TableBase::GetValue ( int  index)
inline

Returns the value at a given index

Parameters
indexIndex of the element
Template Parameters
TType of value (fails if value is not of this type)
Returns
SharedPtr containing the value (or null if failed)
Remarks
This function MUST have its Error handled if it occurred.
template<class F >
TableBase& Sqrat::TableBase::Overload ( const SQChar *  name,
method 
)
inline

Sets a key in the Table to a specific function and allows the key to be overloaded with functions of a different amount of arguments

Parameters
nameThe key in the table being assigned a value
methodFunction that is being placed in the Table
Template Parameters
FType of function (only define this if you need to choose a certain template specialization or overload)
Returns
The Table itself so the call can be chained
Remarks
Overloading in Sqrat does not work for functions with the same amount of arguments (just like in Squirrel).
template<class V >
TableBase& Sqrat::TableBase::SetInstance ( const SQChar *  name,
V *  val 
)
inline

Sets a key in the Table to a specific instance (like a reference)

Parameters
nameThe key in the table being assigned a value
valPointer to the instance that is being placed in the Table
Template Parameters
VType of instance (usually doesnt need to be defined explicitly)
Returns
The Table itself so the call can be chained
template<class V >
TableBase& Sqrat::TableBase::SetInstance ( const SQInteger  index,
V *  val 
)
inline

Sets an index in the Table to a specific instance (like a reference)

Parameters
indexThe index in the table being assigned a value
valPointer to the instance that is being placed in the Table
Template Parameters
VType of instance (usually doesnt need to be defined explicitly)
Returns
The Table itself so the call can be chained
template<class V >
TableBase& Sqrat::TableBase::SetValue ( const SQChar *  name,
const V &  val 
)
inline

Sets a key in the Table to a specific value

Parameters
nameThe key in the table being assigned a value
valValue that is being placed in the Table
Template Parameters
VType of value (usually doesnt need to be defined explicitly)
Returns
The Table itself so the call can be chained
template<class V >
TableBase& Sqrat::TableBase::SetValue ( const SQInteger  index,
const V &  val 
)
inline

Sets an index in the Table to a specific value

Parameters
indexThe index in the table being assigned a value
valValue that is being placed in the Table
Template Parameters
VType of value (usually doesnt need to be defined explicitly)
Returns
The Table itself so the call can be chained
TableBase& Sqrat::TableBase::SquirrelFunc ( const SQChar *  name,
SQFUNCTION  func 
)
inline

Binds a raw Squirrel closure to the Table

Parameters
nameThe key in the table being assigned a function
funcSquirrel function that is being placed in the Table
Returns
The Table itself so the call can be chained

The documentation for this class was generated from the following file: