[gstreamermm] Structure: Remove some uses of GQuark from the API.
- From: Murray Cumming <murrayc src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gstreamermm] Structure: Remove some uses of GQuark from the API.
- Date: Tue, 4 Aug 2009 16:10:50 +0000 (UTC)
commit 6e1b9b785182b87c1b574990ee84a8ee90543a8d
Author: Murray Cumming <murrayc murrayc com>
Date: Tue Aug 4 18:05:24 2009 +0200
Structure: Remove some uses of GQuark from the API.
* gstreamer/src/structure.[hg|ccg]: foreach(), map_in_place(): Use a ustring
instead of a nasty internal GQuark in the slot parameters.
gstreamer/src/structure.ccg | 24 ++++++++++++++++--------
gstreamer/src/structure.hg | 20 +++++++++-----------
2 files changed, 25 insertions(+), 19 deletions(-)
---
diff --git a/gstreamer/src/structure.ccg b/gstreamer/src/structure.ccg
index 36a4f6b..1cdbe83 100644
--- a/gstreamer/src/structure.ccg
+++ b/gstreamer/src/structure.ccg
@@ -22,6 +22,16 @@
#include <gstreamermm/value.h>
#include <gstreamermm/miniobject.h>
+static Glib::ustring quark_to_ustring(GQuark quark)
+{
+ const gchar* pch = g_quark_to_string(quark);
+ Glib::ustring str;
+ if(pch)
+ str = pch;
+
+ return str;
+}
+
static gboolean
Structure_Foreach_gstreamermm_callback(GQuark field_id, const GValue *value, void* data)
{
@@ -31,9 +41,7 @@ Structure_Foreach_gstreamermm_callback(GQuark field_id, const GValue *value, voi
try
{
#endif //GLIBMM_EXCEPTIONS_ENABLED
- bool result = (*slot)(field_id, *reinterpret_cast<const Glib::ValueBase*>(value));
- delete slot;
- return result;
+ return (*slot)(quark_to_ustring(field_id), *reinterpret_cast<const Glib::ValueBase*>(value));
#ifdef GLIBMM_EXCEPTIONS_ENABLED
}
catch(...)
@@ -54,7 +62,7 @@ Structure_Map_gstreamermm_callback(GQuark field_id, GValue *value, void* data)
try
{
#endif //GLIBMM_EXCEPTIONS_ENABLED
- bool result = (*slot)(field_id, *reinterpret_cast<Glib::ValueBase*>(value));
+ bool result = (*slot)(quark_to_ustring(field_id), *reinterpret_cast<Glib::ValueBase*>(value));
delete slot;
return result;
#ifdef GLIBMM_EXCEPTIONS_ENABLED
@@ -405,14 +413,14 @@ bool Structure::get_field(const Glib::ustring& name, Gst::FractionRange& range)
bool Structure::foreach(const SlotForeach& slot)
{
- SlotForeach* slot_copy = new SlotForeach(slot);
- return gst_structure_foreach(gobj(), &Structure_Foreach_gstreamermm_callback, slot_copy);
+ SlotForeach slot_copy(slot); //TODO: Can't we just use slot directly?
+ return gst_structure_foreach(gobj(), &Structure_Foreach_gstreamermm_callback, &slot_copy);
}
bool Structure::map_in_place(const SlotMap& slot)
{
- SlotMap* slot_copy = new SlotMap(slot);
- return gst_structure_map_in_place(gobj(), &Structure_Map_gstreamermm_callback, slot_copy);
+ SlotMap slot_copy = SlotMap(slot); //TODO: Can't we just use slot directly?
+ return gst_structure_map_in_place(gobj(), &Structure_Map_gstreamermm_callback, &slot_copy);
}
Structure Structure::create_from_string(const Glib::ustring& the_string)
diff --git a/gstreamer/src/structure.hg b/gstreamer/src/structure.hg
index 3408a6b..a3cc7f7 100644
--- a/gstreamer/src/structure.hg
+++ b/gstreamer/src/structure.hg
@@ -276,17 +276,15 @@ public:
_WRAP_METHOD(void remove_all_fields(), gst_structure_remove_all_fields)
_WRAP_METHOD(GType get_field_type(const Glib::ustring& fieldname) const, gst_structure_get_field_type)
- //TODO: Remove any use of Quarks from the API, using plain strings instead? They seem like implementation detail. murrayc.
-
/** For example,
- * bool on_foreach(const Glib::QueryQuark& id, const Glib::ValueBase& value);.
- * The foreach function should return true if foreach operation should
- * continue, false if operation should stop with false.
+ * bool on_foreach(const Glib::ustring& id, const Glib::ValueBase& value);.
+ * The foreach function should return true if the foreach operation should
+ * continue, or false if the operation should stop with false.
*/
- typedef sigc::slot<bool, const Glib::QueryQuark&, const Glib::ValueBase&> SlotForeach;
+ typedef sigc::slot<bool, const Glib::ustring&, const Glib::ValueBase&> SlotForeach;
/** Calls the provided slot once for each field in the Gst::Structure. The
- * slot must not modify the fields. Also see map_in_place().
+ * slot must not modify the fields. See also map_in_place().
*
* @param slot A slot to call for each field.
* @return true if the supplied slot returns true For each of the fields,
@@ -487,11 +485,11 @@ public:
bool get_field(const Glib::ustring& fieldname, Gst::FractionRange& value) const;
/** For example,
- * bool on_map(const Glib::QueryQuark& id, Glib::ValueBase& value);.
- * The map function should return true if map operation should continue,
- * false if operation should stop with false.
+ * bool on_map(const Glib::ustring& id, Glib::ValueBase& value);.
+ * The map function should return true if the map operation should continue,
+ * or false if the operation should stop with false.
*/
- typedef sigc::slot<bool, const Glib::QueryQuark&, Glib::ValueBase&> SlotMap;
+ typedef sigc::slot<bool, const Glib::ustring&, Glib::ValueBase&> SlotMap;
/** Calls the provided slot once for each field in the Gst::Structure. In
* contrast to foreach(), the function may modify but not delete the fields.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]