glibmm r552 - in trunk: . gio/giomm



Author: murrayc
Date: Fri Feb  1 23:24:08 2008
New Revision: 552
URL: http://svn.gnome.org/viewvc/glibmm?rev=552&view=rev

Log:
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).

Modified:
   trunk/ChangeLog
   trunk/gio/giomm/contenttype.cc
   trunk/gio/giomm/contenttype.h

Modified: trunk/gio/giomm/contenttype.cc
==============================================================================
--- trunk/gio/giomm/contenttype.cc	(original)
+++ trunk/gio/giomm/contenttype.cc	Fri Feb  1 23:24:08 2008
@@ -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

Modified: trunk/gio/giomm/contenttype.h
==============================================================================
--- trunk/gio/giomm/contenttype.h	(original)
+++ trunk/gio/giomm/contenttype.h	Fri Feb  1 23:24:08 2008
@@ -29,23 +29,23 @@
 
 /**
  * Compares two content types for equality.
-
- * @param type1 a content type string.
- * @param type2 a content type string.
+ *
+ * @param type1 A content type string.
+ * @param type2 A content type string.
  *
  * @return true if the two strings are identical or equivalent, false otherwise.
- **/
+ */
 bool content_type_equals(const Glib::ustring& type1,
                          const Glib::ustring& type2);
 
 /**
- * Determines if @type is a subset of @supertype.
+ * Determines if @a type is a subset of @a supertype.
+ *
+ * @param type A content type string.
+ * @param supertype A string.
  *
- * @param type a content type string.
- * @param supertype a string.
-
  * @return true if @type is a kind of @supertype, false otherwise.
- **/
+ */
 bool content_type_is_a(const Glib::ustring& type,
                        const Glib::ustring& supertype);
 
@@ -54,37 +54,37 @@
  * On unix this is the "application/octet-stream" mimetype,
  * while on win32 it is "*".
  *
- * @param type a content type string.
+ * @param type A content type string.
  *
  * @return true if the type is the unknown type.
- **/
+ */
 bool content_type_is_unknown(const Glib::ustring& type);
 
 /**
  * Gets the human readable description of the content type.
  *
- * @param type a content type string.
+ * @param type A content type string.
  *
  * @return a short description of the content type @type.
- **/
+ */
 Glib::ustring content_type_get_description(const Glib::ustring& type);
 
 /**
  * Gets the mime-type for the content type. If one is registered
  *
- * @param type a content type string.
+ * @param type A content type string.
  *
  * @return the registered mime-type for the given @type, or NULL if unknown.
- **/
+ */
 Glib::ustring content_type_get_mime_type(const Glib::ustring& type);
 
 /**
- * @param type a content type string.
+ * @param type A content type string.
  *
  * Gets the icon for a content type.
  *
  * @return Icon corresponding to the content type.
- **/
+ */
 Glib::RefPtr<Icon> content_type_get_icon(const Glib::ustring& type);
 
 /**
@@ -94,24 +94,37 @@
  * @param type a content type string.
  *
  * @return true if the file type corresponds to a type that can be executable,
- * true otherwise.
- **/
+ * false otherwise.
+ */
 bool content_type_can_be_executable(const Glib::ustring& type);
 
 /**
  * Guesses the content type based on example data. If the function is uncertain,
- * @result_uncertain will be set to true
+ * @a result_uncertain will be set to true
  *
  * @param filename a string.
- * @param data a stream of data.
- * @param data_size the size of @data.
- * @param result_uncertain a flag indicating the certainty of the result.
+ * @param data A stream of data.
+ * @param data_size The size of @data.
+ * @param result_uncertain A flag indicating the certainty of the result.
+ * @return A string indicating a guessed content type for the
+ * given data.
+ */
+Glib::ustring content_type_guess(const std::string& filename,
+                                 const guchar* data, gsize data_size, 
+                                 bool& result_uncertain);
+
+/**
+ * Guesses the content type based on example data. If the function is uncertain,
+ * @a result_uncertain will be set to true
  *
- * Returns: a string indicating a guessed content type for the
+ * @param filename a string.
+ * @param data A stream of data.
+ * @param result_uncertain A flag indicating the certainty of the result.
+ * @return A string indicating a guessed content type for the
  * given data.
- **/
+ */
 Glib::ustring content_type_guess(const std::string& filename,
-                                 const std::basic_string<guchar>& data,
+                                 const std::string& data, 
                                  bool& result_uncertain);
 
 /**
@@ -119,8 +132,8 @@
  * known to the system.
  *
  * @return List of the registered content types.
- **/
-Glib::ListHandle<Glib::ustring> content_types_get_registered(void);
+ */
+Glib::ListHandle<Glib::ustring> content_types_get_registered();
 
 } // namespace Gio
 #endif // _GIOMM_CONTENTTYPE_H



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