lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello,

I use lua_createtable for push std::vectors to my Lua function, it works well. 
I would like to push also the std::map as key-value structure to Lua,
so I have got

lua_createtable(m_lua, p_map.size(), 0);

for( typename std::map<std::string, int>::const_iterator it = p_map.begin(); it != p_map.end(); ++it )

{
  lua_pushstring(m_lua, it->first.c_str());
  lua_pushnumber(m_lua, it->second);
  // should here a pop call on the stack?
}
// should here also a pop call on the stack?

Which calls must be added, so I can use a table in the script, that has a structure
table["key"] = value ?


In this case another question is occured: Can I used also a std::multimap? So can Lua handle tables with
duplicated keys or must be the keys unique?

Thanks

Phil