The Battle for Wesnoth  1.19.18+dev
Public Member Functions | Private Attributes | List of all members
scoped_lua_argument Class Reference

Shallow wrapper around lua_geti which pops the top variable from the Lua stack when destroyed. More...

#include <lua_common.hpp>

Public Member Functions

 scoped_lua_argument (lua_State *L, int arg_index)
 
 scoped_lua_argument (lua_State *L, int value_index, int arg_index)
 
 ~scoped_lua_argument ()
 
 scoped_lua_argument (const scoped_lua_argument &)=delete
 
scoped_lua_argumentoperator= (const scoped_lua_argument &)=delete
 

Private Attributes

lua_State *const state_
 

Detailed Description

Shallow wrapper around lua_geti which pops the top variable from the Lua stack when destroyed.

This is meant to be used in local contexts for quick cleanup of the stack variable.

Todo:
support different get* functions?

Definition at line 52 of file lua_common.hpp.

Constructor & Destructor Documentation

◆ scoped_lua_argument() [1/3]

scoped_lua_argument::scoped_lua_argument ( lua_State *  L,
int  arg_index 
)

Definition at line 511 of file lua_common.cpp.

References state_.

◆ scoped_lua_argument() [2/3]

scoped_lua_argument::scoped_lua_argument ( lua_State *  L,
int  value_index,
int  arg_index 
)

Definition at line 517 of file lua_common.cpp.

References state_.

◆ ~scoped_lua_argument()

scoped_lua_argument::~scoped_lua_argument ( )

Definition at line 523 of file lua_common.cpp.

References state_.

◆ scoped_lua_argument() [3/3]

scoped_lua_argument::scoped_lua_argument ( const scoped_lua_argument )
delete

Member Function Documentation

◆ operator=()

scoped_lua_argument& scoped_lua_argument::operator= ( const scoped_lua_argument )
delete

Member Data Documentation

◆ state_

lua_State* const scoped_lua_argument::state_
private

Definition at line 64 of file lua_common.hpp.

Referenced by scoped_lua_argument(), and ~scoped_lua_argument().


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