summaryrefslogtreecommitdiff
path: root/gio/giomm/contenttype.cc
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@murrayc.com>2008-02-01 23:24:08 +0000
committerMurray Cumming <murrayc@src.gnome.org>2008-02-01 23:24:08 +0000
commit84135b93a20e6c9fe652849959d3ff90474c99bb (patch)
tree9b83ee5eb0f2c5e2e102b6bdeef54c27655b3524 /gio/giomm/contenttype.cc
parentc2cc601439cd40bc8b1f5679e9d9f4ce7fab967b (diff)
downloadglibmm-84135b93a20e6c9fe652849959d3ff90474c99bb.tar.gz
Use convert_return_gchar_ptr_to_ustring() because it releases the gchar*
2008-02-02 Murray Cumming <murrayc@murrayc.com> * gio/giomm/contenttype.cc: * gio/giomm/contenttype.h: Use convert_return_gchar_ptr_to_ustring() because it releases the gchar* and checks for NULL. Removed the ontent_type_guess() that takes a basic_string<guchar> because I doubt anybody would use that. Added one that takes a gchar* and size, and one that takes a std::string (for when the data is a string). svn path=/trunk/; revision=552
Diffstat (limited to 'gio/giomm/contenttype.cc')
-rw-r--r--gio/giomm/contenttype.cc56
1 files changed, 39 insertions, 17 deletions
diff --git a/gio/giomm/contenttype.cc b/gio/giomm/contenttype.cc
index c840acd6..dc268cef 100644
--- a/gio/giomm/contenttype.cc
+++ b/gio/giomm/contenttype.cc
@@ -23,55 +23,77 @@
namespace Gio
{
-bool content_type_equals(const Glib::ustring& type1,
- const Glib::ustring& type2)
+bool content_type_equals(const Glib::ustring& type1, const Glib::ustring& type2)
{
- return g_content_type_equals(type1.c_str(), type2.c_str());
+ return g_content_type_equals(type1.c_str(), type2.c_str());
}
-bool content_type_is_a(const Glib::ustring& type,
- const Glib::ustring& supertype)
+bool content_type_is_a(const Glib::ustring& type, const Glib::ustring& supertype)
{
- return g_content_type_is_a(type.c_str(), supertype.c_str());
+ return g_content_type_is_a(type.c_str(), supertype.c_str());
}
bool content_type_is_unknown(const Glib::ustring& type)
{
- return g_content_type_is_unknown(type.c_str());
+ return g_content_type_is_unknown(type.c_str());
}
Glib::ustring content_type_get_description(const Glib::ustring& type)
{
- return Glib::ustring(g_content_type_get_description(type.c_str()));
+ return Glib::convert_return_gchar_ptr_to_ustring(g_content_type_get_description(type.c_str()));
}
Glib::ustring content_type_get_mime_type(const Glib::ustring& type)
{
- return Glib::ustring(g_content_type_get_mime_type(type.c_str()));
+ return Glib::convert_return_gchar_ptr_to_ustring(g_content_type_get_mime_type(type.c_str()));
}
Glib::RefPtr<Gio::Icon> content_type_get_icon(const Glib::ustring& type)
{
- return Glib::wrap(g_content_type_get_icon(type.c_str()));
+ //TODO: Does g_content_type_get_icon() return a reference?
+ //It currently has no implementation so it's hard to know. murrayc.
+ return Glib::wrap(g_content_type_get_icon(type.c_str()));
}
bool content_type_can_be_executable(const Glib::ustring& type)
{
- return g_content_type_can_be_executable(type.c_str());
+ return g_content_type_can_be_executable(type.c_str());
}
Glib::ustring content_type_guess(const std::string& filename,
- const std::basic_string<guchar>& data,
- bool& result_uncertain)
+ const std::basic_string<guchar>& data, bool& result_uncertain)
{
- return Glib::ustring(g_content_type_guess(filename.c_str(), data.c_str(),
- data.size(), reinterpret_cast<gboolean*>(&result_uncertain)));
+ gboolean c_result_uncertain = FALSE;
+ gchar* cresult = g_content_type_guess(filename.c_str(), data.c_str(),
+ data.size(), &c_result_uncertain);
+ result_uncertain = c_result_uncertain;
+ return Glib::convert_return_gchar_ptr_to_ustring(cresult);
}
-Glib::ListHandle<Glib::ustring> content_types_get_registered(void)
+Glib::ustring content_type_guess(const std::string& filename,
+ const guchar* data, gsize data_size, bool& result_uncertain)
+{
+ gboolean c_result_uncertain = FALSE;
+ gchar* cresult = g_content_type_guess(filename.c_str(), data,
+ data_size, &c_result_uncertain);
+ result_uncertain = c_result_uncertain;
+ return Glib::convert_return_gchar_ptr_to_ustring(cresult);
+}
+
+Glib::ustring content_type_guess(const std::string& filename,
+ const std::string& data, bool& result_uncertain)
+{
+ gboolean c_result_uncertain = FALSE;
+ gchar* cresult = g_content_type_guess(filename.c_str(), (const guchar*)data.c_str(),
+ data.size(), &c_result_uncertain);
+ result_uncertain = c_result_uncertain;
+ return Glib::convert_return_gchar_ptr_to_ustring(cresult);
+}
+
+Glib::ListHandle<Glib::ustring> content_types_get_registered()
{
return Glib::ListHandle<Glib::ustring>(g_content_types_get_registered(),
- Glib::OWNERSHIP_DEEP);
+ Glib::OWNERSHIP_DEEP);
}
} // namespace Gio