prior to returning a std::map<std::string,std::string> to Lua in the project, it was not possible to find the direct return map to Lua. Later through the help of others finally solved the problem. Here's how:
1 luabridge::luaref loginxml::getlocalaccount ()2 {3xmlelement* Rootele = pdoc->rootelement ();4xmlelement* Accountele = rootele->firstchildelement ("LocalAccount");5xmlelement* Childele = accountele->firstchildelement ();6 while(Childele)7 {8STD::stringStrName = Childele->firstchildelement (" Account"),GetText ();9STD::stringStrpwd = Childele->firstchildelement ("Password"),GetText ();TenAccountmap.insert (STD::MAP<STD::string, std::string>:: Value_type (StrName, strpwd)); OneChildele = childele->nextsiblingelement (); A } - -lua_state* luastate = Globalscriptmanager.get_lua_state ();//Get Lua_state the -Luabridge::luaref uniforms (luastate, luabridge::newtable (luastate));//returns a value of one table - -STD::MAP<STD::string, std::string>:: iterator iter; + for(iter = Accountmap.begin (); ITER! = Accountmap.end (); iter++) - { +STD::stringStrName = iter->First ; ASTD::stringStrpwd = iter->second; atUniforms[strname] = strpwd;//Insert value to uniforms - } - - returnuniforms; -}
Just call it right in Lua ...
Loginui.accountlist = loginxml:getlocalaccount () for inpairs do local txt = uiforlua:createtext (k," Microsoft Jas Black ") LoginUI.listAccount:pushBackCustomItem (TXT) End
Luabridge C + + returns map to Lua