Re: [luabind] luabind and std::multimap
Brought to you by:
arvidn,
daniel_wallin
From: Tom N. <td...@sp...> - 2012-02-14 16:08:50
|
I did some work a while ago with direct access to stl containers from lua, I'll see if I can dig up the code this evening. This is a pre-coffee suggestion, but rather than exporting the pairs you may want to consider writing a set of adapters and including them in luabind itself. The one for the multimap itself would present itself as a table. The keys into the table could then be presented as tables themselves which iterate across std::pair< std::lower_bound, std::upper_bound > On 02/14/2012 04:33 AM, irukandji wrote: > Hi everyone, sorry for sending this mail but i wasnt able to find the > answer anywhere else. > > I dont want to make a wrapper around multimap or convert the data to a > table as this brings > useless copying of data, so the idea was to export the std::pair class > and use it as it is > from multimap iterators. The ::first is working just fine and outputs > the data stored as a key, but > the ::second fails and i am unable to figure out why. Can anyone maybe > at least say that this is > not possible so i can stop banging my head against the wall? :) Thank > you in advance... > > // c++ part > std::multimap<std::string, std::string> m_multimap; > > luabind::module(pLuaState) > [ > luabind::class_< std::pair<const std::string, std::string> > > ("MultimapPair") > .property("key",&std::pair<const std::string, std::string>::first ) > .property("val",&std::pair<const std::string, std::string>::second ) > ]; > > luabind::module(pLuaState) > [ > luabind::class_<CTest>("CTest") > .def_readwrite("multimap",&CTest::m_multimap, > luabind::return_stl_iterator) > ]; > > // luapart > function testclass( ctest ) > for data in ctest.multimap do > trace(data.key) > trace(data.value) > end > end > > > > ------------------------------------------------------------------------------ > Keep Your Developer Skills Current with LearnDevNow! > The most comprehensive online learning library for Microsoft developers > is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, > Metro Style Apps, more. Free future releases when you subscribe now! > http://p.sf.net/sfu/learndevnow-d2d > _______________________________________________ > luabind-user mailing list > lua...@li... > https://lists.sourceforge.net/lists/listinfo/luabind-user |