lua/wrappers/util/lua_data_table.cpp
/**
	 * The ipairs function provides similar functionality to that of the Lua ipairs function.
	 * The ipairs function takes a function as it's argument and that function will be
	 * called once per index/value in the data table. If that function returns false
	 * then the loop is stopped.
	 *
	 * <pre>
	 * DataTable = import("DataTable")
	 * table = DataTable.new()
	 * table:push("one", "two", 3)
	 * table:ipairs(function(index, value)\n
	 *     am_log(index .. " = ", value)
	 * end)
	 * -- The output order is not gurrantied
	 * -- 1 = "one"
	 * -- 2 = "two"
	 * -- 3 = 3
	 * </pre>
	 *
	 * @param function handler The each function handler.
	 * @returns DataTable This
	 */
The ipairs function provides similar functionality to that of the Lua ipairs function.
The ipairs function takes a function as it's argument and that function will be
called once per index/value in the data table. If that function returns false
then the loop is stopped.



@param function handler The each function handler.
The ipairs function provides similar functionality to that of the Lua ipairs function . The ipairs function takes a function as it ' s argument and that function will be called once per index / value in the data table . If that function returns false then the loop is stopped . @param function handler The each function handler .
int DataTable_ipairs(lua_State *lua)
	{
		am::util::data::Table *table = castUData<am::util::data::Table>(lua, 1);
		if (table)
		{
			if (lua_isfunction(lua, 2))
			{
				int i = 1;
				for (auto iter = table->beginArray(); iter != table->endArray(); ++iter, ++i)
				{
					lua_pushvalue(lua, 2);
					lua_pushinteger(lua, i);
					if (!pushData(lua, iter->get()))
					{
						lua_pushnil(lua);
					}
					lua_call(lua, 2, 1);
					if (lua_isbool(lua, -1) && !lua_tobool(lua, -1))
					{
						break;
					}
				}
				lua_first(lua);
			}
			return LuaState::expectedArgs(lua, "ipairs", "function handler");
		}
		return LuaState::expectedContext(lua, "ipairs", "DataTable");
	}
int DataTable_ipairs ( lua_State * lua ) { am :: util :: data :: Table * table = castUData < am :: util :: data :: Table > ( lua , 1 ) ; if ( table ) { if ( lua_isfunction ( lua , 2 ) ) { int i = 1 ; for ( auto iter = table -> beginArray ( ) ; iter != table -> endArray ( ) ; ++ iter , ++ i ) { lua_pushvalue ( lua , 2 ) ; lua_pushinteger ( lua , i ) ; if ( ! pushData ( lua , iter -> get ( ) ) ) { lua_pushnil ( lua ) ; } lua_call ( lua , 2 , 1 ) ; if ( lua_isbool ( lua , -1 ) && ! lua_tobool ( lua , -1 ) ) { break ; } } lua_first ( lua ) ; } return LuaState :: expectedArgs ( lua , " " , " " ) ; } return LuaState :: expectedContext ( lua , " " , " " ) ; }
The ipairs function provides similar functionality to that of the Lua ipairs function.
The ipairs function provides similar functionality to that of the Lua ipairs function .