[glibmm] VariantType: Add create_tuple().
- From: Josà Alburquerque <jaalburqu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] VariantType: Add create_tuple().
- Date: Wed, 21 Nov 2012 03:58:59 +0000 (UTC)
commit fadf0377c5f4513ddc2175a091d55fe76d7a44a4
Author: Andrew Potter <agpotter gmail com>
Date: Tue Nov 20 19:13:58 2012 -0500
VariantType: Add create_tuple().
* glib/src/varianttype.{ccg,hg}: Add the method following the style of
VariantContainerBase::create_tuple(), completing a TODO.
Bug #688682.
ChangeLog | 9 +++++++++
glib/src/varianttype.ccg | 15 +++++++++++++++
glib/src/varianttype.hg | 12 ++++++++++--
3 files changed, 34 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a5907db..d63742f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2012-11-20 Andrew Potter <agpotter gmail com>
+
+ VariantType: Add create_tuple().
+
+ * glib/src/varianttype.{ccg,hg}: Add the method following the style of
+ VariantContainerBase::create_tuple(), completing a TODO.
+
+ Bug #688682.
+
2012-11-20 Josà Alburquerque <jaalburquerque gmail com>
VariantType: Correct the referencing in the create*() methods.
diff --git a/glib/src/varianttype.ccg b/glib/src/varianttype.ccg
index 6cd317e..5493ead 100644
--- a/glib/src/varianttype.ccg
+++ b/glib/src/varianttype.ccg
@@ -51,6 +51,21 @@ VariantType& VariantType::operator=(const GVariantType* castitem)
}
+VariantType VariantType::create_tuple(const std::vector<VariantType>& items)
+{
+ typedef GVariantType* var_ptr;
+ var_ptr* const var_array = new var_ptr[items.size()];
+
+ for(std::vector<VariantType>::size_type i = 0; i < items.size(); i++)
+ {
+ var_array[i] = const_cast<GVariantType*>(items[i].gobj());
+ }
+
+ VariantType result = Glib::wrap(g_variant_type_new_tuple(var_array, items.size()));
+ delete[] var_array;
+ return result;
+}
+
const VariantType VARIANT_TYPE_BOOL(G_VARIANT_TYPE_BOOLEAN);
const VariantType VARIANT_TYPE_BYTE(G_VARIANT_TYPE_BYTE);
diff --git a/glib/src/varianttype.hg b/glib/src/varianttype.hg
index e5e8973..5cc8f7f 100644
--- a/glib/src/varianttype.hg
+++ b/glib/src/varianttype.hg
@@ -20,6 +20,7 @@ _DEFS(glibmm,glib)
#include <glibmmconfig.h>
#include <glib-object.h> //For gsize
#include <string>
+#include <vector>
#ifndef DOXYGEN_SHOULD_SKIP_THIS
typedef struct _GVariantType GVariantType;
@@ -113,8 +114,15 @@ public:
_WRAP_METHOD(static VariantType create_array(const VariantType& element), g_variant_type_new_array)
_WRAP_METHOD(static VariantType create_maybe(const VariantType& element), g_variant_type_new_maybe)
- //TODO: Use a single list parameter:
- //_WRAP_METHOD(static VariantType create_tuple(const GVariantType * const *items, gint length), g_variant_type_new_tuple)
+ /** Constructs a new tuple type, from @a items.
+ *
+ * @param items A vector of VariantTypes, one for each item.
+ * @return A new tuple VariantType.
+ *
+ * @newin{2,36}
+ */
+ static VariantType create_tuple(const std::vector<VariantType>& items);
+ _IGNORE(g_variant_type_new_tuple)
_WRAP_METHOD(static VariantType create_dict_entry(const VariantType& key, const VariantType& value), g_variant_type_new_dict_entry)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]