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

Wrapper for a Lua state. More...

#include <state.hpp>

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

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 First , typename Second , typename... Rest>
void luwra::StateWrapper::push ( First &&  first,
Second &&  second,
Rest &&...  rest 
) const
inline

◆ push() [2/2]

template<typename Type >
void luwra::StateWrapper::push ( Type &&  value) 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