本文整理汇总了C++中LuaState::Next方法的典型用法代码示例。如果您正苦于以下问题:C++ LuaState::Next方法的具体用法?C++ LuaState::Next怎么用?C++ LuaState::Next使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LuaState
的用法示例。
在下文中一共展示了LuaState::Next方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Next
/**
Go to the next entry in the table.
\return Returns true if the iteration is done.
**/
bool LuaStackTableIterator::Next()
{
// This function is only active if Reset() has been called head.
luaplus_assert( IsValid() );
// This is a local helper variable so we don't waste space in the class
// definition.
LuaState* state = m_tableObj.GetState();
// Do any stack management operations.
if ( m_autoStackManagement )
{
state->SetTop( m_startStackIndex + 1 );
}
else
{
// If this luaplus_assert fires, then you left something on the stack.
luaplus_assert( state->GetTop() == m_startStackIndex + 1 );
}
// Do the Lua table iteration.
if ( state->Next( m_tableObj ) == 0 )
{
// Invalidate the iterator.
m_startStackIndex = -1;
return false;
}
// The iterator is still valid.
return true;
}
示例2: Reset
/**
Start iteration at the beginning of the table.
**/
void LuaStackTableIterator::Reset()
{
// Start afresh...
LuaState* state = m_tableObj.GetState();
m_startStackIndex = state->GetTop();
// Push the head stack entry.
state->PushNil();
// Start the iteration. If the return value is 0, then the iterator
// will be invalid.
if ( state->Next( m_tableObj ) == 0 )
m_startStackIndex = -1;
}