Re: For 0.9? Avoiding string copy
Daniel Wallin <[email protected]>
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
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