Re: Get gchar* from Glib::ustring



Thank you.

Can you say why the following code compile but don't work?


template <class T1, class T2, class T3>
Glib::ustring build_filename(const T1& str1, const T2& str2, const T3& str3)
{
    Glib::ustring ustr1 = Glib::ustring::compose("%1", str1);
    Glib::ustring ustr2 = Glib::ustring::compose("%1", str2);
    Glib::ustring ustr3 = Glib::ustring::compose("%1", str3);

    gchar* path;

    path = g_build_filename(ustr1.c_str(), ustr2.c_str(), ustr3.c_str());

    Glib::ustring r_path(path);
    g_free(path);
    return r_path;
}

2009/6/3 Philipp Kerling <pkerling casix org>
Hi,

Am Mittwoch, den 03.06.2009, 14:33 -0300 schrieb Fabrício Godoy:
> Hi everyone,
>
> How I get/convert gchar* from Glib::ustring?
You can just use the Glib::ustring member functions data() or c_str()
[1], the returned char* is basically the same as gchar* [2].

[1] http://www.gtkmm.org/docs/glibmm-2.4/docs/reference/html/classGlib_1_1ustring.html#a3df2e7bde58b48d8a980869f95cc442
[2] http://developer.gimp.org/api/2.0/glib/glib-Basic-Types.html#gchar

Regards,
Philipp



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