Re: std::string vs other strings

Cory Riddell <[email protected]> Mon, 12 Nov 2012 09:47:22 -0600
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <[email protected]>
Thank you for the pointer. It ended up being incredibly simple. Here's
my code for CString:

namespace luabind
{
    template <>
    struct default_converter<CString>
      : native_converter_base<CString>
    {
        static int compute_score(lua_State* L, int index)
        {
            return lua_type(L, index) == LUA_TSTRING ? 0 : -1;
        }

        CString from(lua_State* L, int index)
        {
            return CString(lua_tostring(L, index), lua_rawlen(L, index));
        }

        void to(lua_State* L, CString const& value)
        {
            lua_pushlstring(L, (LPCTSTR)value, value.GetLength());
        }
    };

    template <>
    struct default_converter<CString const>
      : default_converter<CString>
    {};

    template <>
    struct default_converter<CString const&>
      : default_converter<CString>
    {};
}


The only possible problem that I can see here is needing to convert from
wchar_t to char (utf-8) when making a unicode build.

Cory



On 11/9/2012 3:35 PM, Willi Schinmeyer wrote:
> The std::string converter seems to be defined in detail/policy.hpp:756 
> as a specialization of default_converter. I'd start my investigation there.
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_nov
> _______________________________________________
> luabind-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/luabind-user
>


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov