Luwra
Minimal-overhead Lua wrapper for C++
Public Member Functions | List of all members
luwra::StateWrapper Struct Reference

Wrapper for a Lua state. More...

Inherits luwra::internal::StateBundle, and luwra::Table.

Public Member Functions

template<typename Callable , typename... ExtraArgs>
internal::ReturnTypeOf< Callable > apply (int pos, Callable &&func, ExtraArgs &&... args) const
 See luwra::apply. More...
 
bool equal (int index1, int index2) const
 See luwra::equal. More...
 
void loadStandardLibrary () const
 Load all built-in libraries. More...
 
template<typename Callable , typename... ExtraArgs>
size_t map (int pos, Callable &&func, ExtraArgs &&... args) const
 See luwra::map. More...
 
 operator State * () const
 Convert to lua_State. More...
 
template<typename Type >
const StateWrapperoperator<< (Type &&value) const
 See luwra::push. More...
 
template<typename Type >
void push (Type &&value) const
 See luwra::push. More...
 
template<typename First , typename Second , typename... Rest>
void push (First &&first, Second &&second, Rest &&... rest) const
 See luwra::push. More...
 
template<typename Type = internal::InferValueType>
Type read (int index) const
 See luwra::read. More...
 
template<typename Sig >
void registerUserType (const char *ctor_name, const MemberMap &methods=MemberMap(), const MemberMap &meta_methods=MemberMap()) const
 See luwra::registerUserType. More...
 
template<typename UserType >
void registerUserType (const MemberMap &methods=MemberMap(), const MemberMap &meta_methods=MemberMap()) const
 See luwra::registerUserType. More...
 
int runFile (const char *filepath) const
 Execute a file. More...
 
int runString (const char *code) const
 Execute a piece of code. More...
 
void setMetatable (const char *name) const
 See luwra::setMetatable. More...
 
 StateWrapper ()
 Create a new Lua state. More...
 
 StateWrapper (State *other)
 Operate on a foreign state instance. More...
 
- Public Member Functions inherited from luwra::internal::StateBundle
 StateBundle ()
 
 StateBundle (State *other)
 
- Public Member Functions inherited from luwra::Table
template<typename Key >
const internal::TableAccessorPath< const Reference &, Key > access (Key &&key) const
 Identical to operator[]. More...
 
template<typename Type , typename Key >
Type get (Key &&key) const
 Retrieve the value of a field. More...
 
template<typename Key >
bool has (Key &&key) const
 Check if the value associated with a key is not nil. More...
 
template<typename Key >
const internal::TableAccessorPath< const Reference &, Key > operator[] (Key &&key) const
 Create an accessor to a field of the table. More...
 
template<typename Type , typename Key >
void set (Key &&key, Type &&value) const
 Update a field. More...
 
 Table (const Reference &ref)
 Create from reference. More...
 
 Table (State *state, int index)
 Create from table on the stack. More...
 
 Table (State *state)
 Create a new table. More...
 
 Table (State *state, const MemberMap &fields)
 Create a new table with the given fields. More...
 
void update (const MemberMap &fields) const
 Update the table using the given map of members. More...
 

Additional Inherited Members

- Public Attributes inherited from luwra::internal::StateBundle
std::shared_ptr< Statestate
 
- Public Attributes inherited from luwra::Table
Reference ref
 

Detailed Description

Wrapper for a Lua state.

Constructor & Destructor Documentation

§ StateWrapper() [1/2]

luwra::StateWrapper::StateWrapper ( )
inline

Create a new Lua state.

§ StateWrapper() [2/2]

luwra::StateWrapper::StateWrapper ( State other)
inline

Operate on a foreign state instance.

Member Function Documentation

§ apply()

template<typename Callable , typename... ExtraArgs>
internal::ReturnTypeOf<Callable> luwra::StateWrapper::apply ( int  pos,
Callable &&  func,
ExtraArgs &&...  args 
) const
inline

§ equal()

bool luwra::StateWrapper::equal ( int  index1,
int  index2 
) const
inline

§ loadStandardLibrary()

void luwra::StateWrapper::loadStandardLibrary ( ) const
inline

Load all built-in libraries.

§ map()

template<typename Callable , typename... ExtraArgs>
size_t luwra::StateWrapper::map ( int  pos,
Callable &&  func,
ExtraArgs &&...  args 
) const
inline

See luwra::map.

§ operator State *()

luwra::StateWrapper::operator State * ( ) const
inline

Convert to lua_State.

§ operator<<()

template<typename Type >
const StateWrapper& luwra::StateWrapper::operator<< ( Type &&  value) const
inline

§ push() [1/2]

template<typename Type >
void luwra::StateWrapper::push ( Type &&  value) const
inline

§ push() [2/2]

template<typename First , typename Second , typename... Rest>
void luwra::StateWrapper::push ( First &&  first,
Second &&  second,
Rest &&...  rest 
) const
inline

§ read()

template<typename Type = internal::InferValueType>
Type luwra::StateWrapper::read ( int  index) const
inline

§ registerUserType() [1/2]

template<typename Sig >
void luwra::StateWrapper::registerUserType ( const char *  ctor_name,
const MemberMap methods = MemberMap(),
const MemberMap meta_methods = MemberMap() 
) const
inline

§ registerUserType() [2/2]

template<typename UserType >
void luwra::StateWrapper::registerUserType ( const MemberMap methods = MemberMap(),
const MemberMap meta_methods = MemberMap() 
) const
inline

§ runFile()

int luwra::StateWrapper::runFile ( const char *  filepath) const
inline

Execute a file.

§ runString()

int luwra::StateWrapper::runString ( const char *  code) const
inline

Execute a piece of code.

§ setMetatable()

void luwra::StateWrapper::setMetatable ( const char *  name) const
inline