summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjell Ahlstedt <kjell.ahlstedt@bredband.net>2016-12-23 15:28:55 +0100
committerKjell Ahlstedt <kjell.ahlstedt@bredband.net>2016-12-23 15:28:55 +0100
commit73ec1aa8e64a6cf316dbf4c3f4d8c5c1b52157c7 (patch)
tree30f8d2590148da7e919fa355f73028f2a46e22cd
parentd21708ed12fe3ccbcfcf28eb4b845bfa3d1fe255 (diff)
downloadglibmm-73ec1aa8e64a6cf316dbf4c3f4d8c5c1b52157c7.tar.gz
Glib::VariantType: Add get_item_types()
Remove Glib::VariantType::first() and next(). Replace them with get_item_types(). Bug 775741
-rw-r--r--glib/src/varianttype.ccg13
-rw-r--r--glib/src/varianttype.hg22
2 files changed, 32 insertions, 3 deletions
diff --git a/glib/src/varianttype.ccg b/glib/src/varianttype.ccg
index 8274c931..d4032c10 100644
--- a/glib/src/varianttype.ccg
+++ b/glib/src/varianttype.ccg
@@ -122,4 +122,17 @@ VariantType::get_string() const
{
return std::string(g_variant_type_peek_string(gobj()), g_variant_type_get_string_length(gobj()));
}
+
+std::vector<VariantType> VariantType::get_item_types() const
+{
+ std::vector<VariantType> result;
+ auto next_item_type = g_variant_type_first(gobj());
+ while (next_item_type)
+ {
+ result.emplace_back(const_cast<GVariantType*>(next_item_type), true);
+ next_item_type = g_variant_type_next(next_item_type);
+ }
+ return result;
}
+
+} // namespace GLib
diff --git a/glib/src/varianttype.hg b/glib/src/varianttype.hg
index 19327ab4..509eaa6e 100644
--- a/glib/src/varianttype.hg
+++ b/glib/src/varianttype.hg
@@ -162,15 +162,31 @@ public:
_WRAP_METHOD(bool is_subtype_of(const VariantType& supertype) const, g_variant_type_is_subtype_of)
// It's necessary to take an extra reference of the 'const GVariantType*'
-// returned by g_variant_type_element() because it doesn't do that already.
+// returned by g_variant_type_element(), g_variant_type_key() and
+// g_variant_type_value() because they don't do that already.
#m4 _CONVERSION(`const GVariantType*',`VariantType',`Glib::wrap(const_cast<GVariantType*>($3), true)')
_WRAP_METHOD(VariantType element() const, g_variant_type_element)
- _WRAP_METHOD(VariantType first() const, g_variant_type_first)
- _WRAP_METHOD(VariantType next () const, g_variant_type_next)
_WRAP_METHOD(gsize n_items() const, g_variant_type_n_items)
_WRAP_METHOD(VariantType key() const, g_variant_type_key)
_WRAP_METHOD(VariantType value() const, g_variant_type_value)
+ /** Determines the item types of a tuple or dictionary entry type.
+ *
+ * This function may only be used with tuple or dictionary entry types,
+ * but must not be used with the generic tuple type VARIANT_TYPE_TUPLE.
+ *
+ * In the case of a dictionary entry type, returns a vector with
+ * 2 elements, the type of the key followed by the value type.
+ *
+ * An empty vector is returned in case of this %VariantType being VARIANT_TYPE_UNIT.
+ *
+ * @newin{2,52}
+ *
+ * @return The item types of this %VariantType, or an empty vector.
+ */
+ std::vector<VariantType> get_item_types() const;
+ _IGNORE(g_variant_type_first, g_variant_type_next)
+
// This function is part of unexposed API in gvarianttypeinfo.{h,c} for an
// also unexposed GVariantTypeInfo structure of glib.
_IGNORE(g_variant_type_info_get)