summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjell Ahlstedt <kjellahlstedt@gmail.com>2017-05-05 16:01:27 +0200
committerKjell Ahlstedt <kjellahlstedt@gmail.com>2017-05-05 16:01:27 +0200
commit0fb72be491466cf4b20e90aea169d122b21858bd (patch)
tree8a9b12a56b053df6d3eef87dc7b5cf8d0bc71b6e
parentbb5865cb1d01b8ba2d76224e660e0509083dde58 (diff)
downloadglibmm-0fb72be491466cf4b20e90aea169d122b21858bd.tar.gz
Glib::VariantType: Deprecate first() and next(). Add get_item_types()
Bug 775741
-rw-r--r--glib/src/varianttype.ccg13
-rw-r--r--glib/src/varianttype.hg23
2 files changed, 33 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..0cac0feb 100644
--- a/glib/src/varianttype.hg
+++ b/glib/src/varianttype.hg
@@ -162,15 +162,32 @@ 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(VariantType first() const, g_variant_type_first, deprecated "Use get_item_types() instead.")
+ _WRAP_METHOD(VariantType next () const, g_variant_type_next, deprecated "Use get_item_types() instead.")
_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;
+
// 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)