Re: For 0.9? Avoiding string copy
Kristoffer Danielsson <[email protected]>
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
Thanks a lot! So I simply instantiate this class and pass it to call_function? > Date: Wed, 9 Dec 2009 17:58:01 +0100 > From: [email protected] > To: [email protected] > Subject: Re: [luabind] For 0.9? Avoiding string copy > > Kristoffer Danielsson wrote: > > Any chance you could add such a wrapper for 0.9? It's really painful > > to copy strings that do not need to be copied! > > 0.9 is (mostly) in feature freeze, so I won't add anything like that at > least for now. You can easily do it by yourself though: > > struct cstring_with_length > { > cstring_with_length(char const* s, std::size_t len) > : s(s) > , len(len) > {} > > char const* s; > std::size_t len; > }; > > namespace luabind > { > > template <> > struct default_converter<cstring_with_length> > : native_converter_base<cstring_with_length> > { > void to(lua_State* L, cstring_with_length const& str) > { > lua_pushlstring(L, str.s, str.len); > } > }; > > } // namespace luabind > > -- > Daniel Wallin > BoostPro Computing > http://www.boostpro.com > > ------------------------------------------------------------------------------ > Return on Information: > Google Enterprise Search pays you back > Get the facts. > http://p.sf.net/sfu/google-dev2dev > _______________________________________________ > luabind-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/luabind-user _________________________________________________________________ Nya Windows 7 gör allt lite enklare. Hitta en dator som passar dig! http://windows.microsoft.com/shop ------------------------------------------------------------------------------ Return on Information: Google Enterprise Search pays you back Get the facts. http://p.sf.net/sfu/google-dev2dev _______________________________________________ luabind-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/luabind-user