OOLua  2.0.1
C++ and Lua binding
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
oolua_table.h File Reference

Interface for the Lua unordered and ordered associative container. More...

#include "lua_includes.h"
#include <string>
#include "oolua_stack_fwd.h"
#include "oolua_ref.h"
#include "oolua_config.h"
#include "oolua_error.h"

Classes

class  OOLUA::Table
 Wrapper around a table in Lua which allows easy usage. More...
 

Namespaces

 OOLUA
 This is the root namespace of the Library.
 

Macros

#define oolua_ipairs(table)
 Helper for iterating over the sequence part of a table. More...
 
#define oolua_ipairs_end()
 
#define oolua_pairs(table)
 Helper for iterating over a table. More...
 
#define oolua_pairs_end()
 

Functions

template<typename T , typename T1 >
void OOLUA::table_set_value (lua_State *vm, int table_index, T const &key, T1 const &value)
 The table is at table_index which can be either absolute or pseudo in the stack table is left at the index.
 
template<typename T , typename T1 >
bool OOLUA::table_at (lua_State *vm, int const table_index, T const &key, T1 &value)
 The table is at table_index which can be either absolute or pseudo in the stack table is left at the index.
 
void OOLUA::new_table (lua_State *vm, OOLUA::Table &t)
 Creates a new valid OOLUA::Table. More...
 
OOLUA::Table OOLUA::new_table (lua_State *vm)
 Creates a new valid Table. More...
 

Detailed Description

Interface for the Lua unordered and ordered associative container.

Macro Definition Documentation

#define oolua_ipairs (   table)

Helper for iterating over the sequence part of a table.

Parameters
table

Declares:

  • int _i_index_ : Current index into the array
  • int const _oolua_array_index_ : Stack index at which table is located
  • lua_State* lvm : The vm associated with the table
Note
Returning from inside of the loop will not leave the stack clean unless you reset it. usage:
{
if(_i_index_ == 99)
{
lua_settop(lvm,_oolua_array_index-1);
return "red balloons";
}
}
return "Not enough balloons to go bang."
#define oolua_ipairs_end ( )
See Also
oolua_ipairs
#define oolua_pairs (   table)

Helper for iterating over a table.

Parameters
table

When iterating over a table, for the next iteration to work you must leave the key on the top of the stack. If you need to work with the key, it is a good idea to use lua_pushvalue to duplicate it on the stack. This is because if the type is not a string and you retrieve a string from the stack with lua_tostring, this will alter the vm's stack entry.
Declares:

  • int const _oolua_table_index_ : Stack index at which table is located
  • lua_State* lvm : The vm associated with the table

usage:

{
\\do what ever
lua_pop(vm, 1);\\Pop the value, leaving the key at the top of stack
}
#define oolua_pairs_end ( )
See Also
oolua_pairs