Re: Wrapping gboolean list[] for Glib::KeyFile



"Yes, please use bool, and never use gboolean in public API. Is there
an actual problem with the conversion in this case?"

I'll try and make the problem clearer by posting the code here:

Glib::ArrayHandle<bool> KeyFile::get_boolean_list(const Glib::ustring&
group_name, const Glib::ustring& key){
        gboolean* bool_list  = 0;
        gsize length_of_list = 0;
        GError* error        = 0;

        bool_list = g_key_file_get_boolean_list(gobj(),
group_name.c_str(), key.c_str(), &length_of_list, &error);

        if(error)
                Glib::Error::throw_exception(error);

        return Glib::ArrayHandle<bool>(bool_list, length_of_list,
Glib::OWNERSHIP_DEEP);

}

g_key_file_get_boolean_list returns a gboolean*, which works fine,
however, the Glib::ArrayHandle<bool> constructor requires a bool* as
its first argument and it doesn't seem able to do an implicit
conversion from gboolean*.

So, I either need a way to convert bool_list from a gboolean* to a bool*
OR
I need to be able to convert Glib::ArrayHandle<gboolean> to
Glib::ArrayHandle<bool>

Alternatively... I'm not seeing a really obvious way of doing this.
Which is very possible :-)

Hope this makes it clearer.

Rob.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]