Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Member Functions | Protected Attributes | List of all members
cLuaState::cStackTable Class Reference

Represents a table on the Lua stack. More...

#include <LuaState.h>

Collaboration diagram for cLuaState::cStackTable:
Collaboration graph
[legend]

Public Member Functions

 cStackTable (cLuaState &a_LuaState, int a_StackPos)
 
void ForEachArrayElement (cFunctionRef< bool(cLuaState &a_LuaState, int a_Index)> a_ElementCallback) const
 Iterates over all array elements in the table consecutively and calls the a_ElementCallback for each. More...
 
void ForEachElement (cFunctionRef< bool(cLuaState &a_LuaState)> a_ElementCallback) const
 Iterates over all dictionary elements in the table in random order, and calls the a_ElementCallback for each of them. More...
 
cLuaStateGetLuaState (void) const
 

Protected Attributes

cLuaStatem_LuaState
 The Lua state in which the table resides. More...
 
int m_StackPos
 The stack index where the table resides in the Lua state. More...
 

Detailed Description

Represents a table on the Lua stack.

Provides easy access to the elements in the table. Note that this class doesn't have cTrackedRef's thread-safeness and unload-safeness, it is expected to be used for immediate queries in API bindings.

Definition at line 515 of file LuaState.h.

Constructor & Destructor Documentation

◆ cStackTable()

cLuaState::cStackTable::cStackTable ( cLuaState a_LuaState,
int  a_StackPos 
)

Definition at line 375 of file LuaState.cpp.

Member Function Documentation

◆ ForEachArrayElement()

void cLuaState::cStackTable::ForEachArrayElement ( cFunctionRef< bool(cLuaState &a_LuaState, int a_Index)>  a_ElementCallback) const

Iterates over all array elements in the table consecutively and calls the a_ElementCallback for each.

The callback receives the LuaState in which the table resides, and the element's index. The LuaState has the element on top of its stack. If the callback returns true, the iteration is aborted, if it returns false, the iteration continues with the next element.

Definition at line 386 of file LuaState.cpp.

◆ ForEachElement()

void cLuaState::cStackTable::ForEachElement ( cFunctionRef< bool(cLuaState &a_LuaState)>  a_ElementCallback) const

Iterates over all dictionary elements in the table in random order, and calls the a_ElementCallback for each of them.

The callback receives the LuaState in which the table reside. The LuaState has the element on top of its stack, and the element's key just below it. If the callback returns true, the iteration is aborted, if it returns false, the iteration continues with the next element.

Definition at line 409 of file LuaState.cpp.

◆ GetLuaState()

cLuaState& cLuaState::cStackTable::GetLuaState ( void  ) const
inline

Definition at line 533 of file LuaState.h.

Member Data Documentation

◆ m_LuaState

cLuaState& cLuaState::cStackTable::m_LuaState
protected

The Lua state in which the table resides.

Definition at line 537 of file LuaState.h.

◆ m_StackPos

int cLuaState::cStackTable::m_StackPos
protected

The stack index where the table resides in the Lua state.

Definition at line 540 of file LuaState.h.


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