summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@murrayc.com>2011-03-29 11:15:30 +0200
committerMurray Cumming <murrayc@murrayc.com>2011-03-29 11:16:40 +0200
commit85252750b27d79458f6b91763c34c1829eac491b (patch)
treeb614b0755a9be7d5d373c71eb5c3d4c87417b70b
parent00a2fa0f7f7fa2b998e8812e677a239f5d62ec49 (diff)
downloadglibmm-85252750b27d79458f6b91763c34c1829eac491b.tar.gz
Variant: Rename get(index) to get_child(index).
* glib/src/variant.[hg|ccg]: Rename all get() methods that return children to get_child() to make the API clearer and to avoid ambiguity with get() methods that return the underlying type instead. * examples/dbus/peer.cc: * examples/dbus/userbus.cc: * tests/glibmm_variant/main.cc: Adapted. https://bugzilla.gnome.org/show_bug.cgi?id=644207#c7 (Yannick Guesnet)
-rw-r--r--ChangeLog13
-rw-r--r--examples/dbus/peer.cc4
-rw-r--r--examples/dbus/userbus.cc2
-rw-r--r--glib/src/variant.ccg6
-rw-r--r--glib/src/variant.hg24
-rw-r--r--tests/glibmm_variant/main.cc4
6 files changed, 33 insertions, 20 deletions
diff --git a/ChangeLog b/ChangeLog
index 1b505a9b..15645ad5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2011-03-29 Murray Cumming <murrayc@murrayc.com>
+
+ Variant: Rename get(index) to get_child(index).
+
+ * glib/src/variant.[hg|ccg]: Rename all get() methods that return children
+ to get_child() to make the API clearer and to avoid ambiguity with get()
+ methods that return the underlying type instead.
+ * examples/dbus/peer.cc:
+ * examples/dbus/userbus.cc:
+ * tests/glibmm_variant/main.cc: Adapted.
+ https://bugzilla.gnome.org/show_bug.cgi?id=644207#c7
+ (Yannick Guesnet)
+
2011-03-29 Murray Cumming <murrayc@murrayc-desktop>
FileUtils: Correct my previous commit.
diff --git a/examples/dbus/peer.cc b/examples/dbus/peer.cc
index c35bab8e..99cdb66b 100644
--- a/examples/dbus/peer.cc
+++ b/examples/dbus/peer.cc
@@ -120,7 +120,7 @@ static void on_method_call(const Glib::RefPtr<Gio::DBus::Connection>&,
// Get (expected) single string in tupple.
Glib::Variant<Glib::ustring> param;
- parameters.get(param);
+ parameters.get_child(param);
Glib::ustring response = "You said: '" + param.get() + "'.";
@@ -266,7 +266,7 @@ void run_as_client(Glib::ustring address)
"HelloWorld", parameters);
Glib::Variant<Glib::ustring> child;
- result.get(child);
+ result.get_child(child);
std::cout << "The server said: " << child.get() << "." << std::endl;
diff --git a/examples/dbus/userbus.cc b/examples/dbus/userbus.cc
index 845db3b8..89f942fa 100644
--- a/examples/dbus/userbus.cc
+++ b/examples/dbus/userbus.cc
@@ -53,7 +53,7 @@ void dbus_proxy_available(Glib::RefPtr<Gio::AsyncResult>& result)
// Now extract the single item in the variant container which is the
// array of strings (the names).
Glib::Variant< std::vector<Glib::ustring> > names_variant;
- result.get(names_variant);
+ result.get_child(names_variant);
// Get the vector of strings.
std::vector<Glib::ustring> names = names_variant.get();
diff --git a/glib/src/variant.ccg b/glib/src/variant.ccg
index f18f03c6..eaa4829c 100644
--- a/glib/src/variant.ccg
+++ b/glib/src/variant.ccg
@@ -103,7 +103,7 @@ VariantContainerBase::create_tuple(const std::vector<VariantBase>& children)
return result;
}
-void VariantContainerBase::get(VariantBase& child, gsize index) const
+void VariantContainerBase::get_child(VariantBase& child, gsize index) const
{
if(index >= g_variant_n_children(gobject_))
throw std::out_of_range(
@@ -367,7 +367,7 @@ Variant<type_vec_ustring>::create(const type_vec_ustring& data)
return result;
}
-Glib::ustring Variant<type_vec_ustring>::get(gsize index) const
+Glib::ustring Variant<type_vec_ustring>::get_child(gsize index) const
{
gsize n_elements = 0;
@@ -460,7 +460,7 @@ Variant<type_vec_string>::create(const type_vec_string& data)
return result;
}
-std::string Variant<type_vec_string>::get(gsize index) const
+std::string Variant<type_vec_string>::get_child(gsize index) const
{
gsize n_elements = 0;
diff --git a/glib/src/variant.hg b/glib/src/variant.hg
index 2508d9de..83d8b089 100644
--- a/glib/src/variant.hg
+++ b/glib/src/variant.hg
@@ -293,15 +293,15 @@ public:
* @throw std::out_of_range
* @newin{2,28}
*/
- void get(VariantBase& child, gsize index = 0) const;
+ void get_child(VariantBase& child, gsize index = 0) const;
_IGNORE(g_variant_get_child, g_variant_get_child_value)
- _WRAP_METHOD(VariantBase get(gsize index = 0), g_variant_get_child_value)
+ _WRAP_METHOD(VariantBase get_child(gsize index = 0), g_variant_get_child_value)
/* TODO?:
/// A get() method to return the contents of the variant in the container.
template <class DataType>
- DataType get(gsize index = 0) const;
+ DataType get_child(gsize index = 0) const;
*/
/** If this is a maybe-typed instance, extract its value. If the value is
@@ -588,7 +588,7 @@ public:
* @throw std::out_of_range
* @newin{2,28}
*/
- T get(gsize index) const;
+ T get_child(gsize index) const;
/** Gets the vector of the Variant.
* @return The vector.
@@ -652,7 +652,7 @@ public:
* @throw std::out_of_range
* @newin{2,28}
*/
- Glib::ustring get(gsize index) const;
+ Glib::ustring get_child(gsize index) const;
/** Gets the string vector of the Variant.
* @return The vector.
@@ -716,7 +716,7 @@ public:
* @throw std::out_of_range
* @newin{2,28}
*/
- std::string get(gsize index) const;
+ std::string get_child(gsize index) const;
/** Gets the string vector of the Variant.
* @return The vector.
@@ -784,7 +784,7 @@ public:
* @throw std::out_of_range
* @newin{2,28}
*/
- std::pair<K, V> get(gsize index) const;
+ std::pair<K, V> get_child(gsize index) const;
/** Looks up a value in a dictionary Variant.
* @param key The key to look up.
@@ -867,11 +867,11 @@ std::pair<K, V> Variant< std::pair<K, V> >::get() const
{
// Get the key (the first element of the this VariantContainerBase).
Variant<K> key;
- VariantContainerBase::get(key, 0);
+ VariantContainerBase::get_child(key, 0);
// Get the value (the second element of the this VariantContainerBase).
Variant<V> value;
- VariantContainerBase::get(value, 1);
+ VariantContainerBase::get_child(value, 1);
std::pair<K, V> result(key.get(), value.get());
@@ -923,7 +923,7 @@ Variant< std::vector<T> >::create(const std::vector<T>& data)
}
template<class T>
-T Variant< std::vector<T> >::get(gsize index) const
+T Variant< std::vector<T> >::get_child(gsize index) const
{
gsize n_elements = 0;
@@ -1016,10 +1016,10 @@ Variant< std::map<K, V> >::create(const std::map<K, V>& data)
template<class K, class V>
std::pair<K, V>
-Variant< std::map<K, V> >::get(gsize index) const
+Variant< std::map<K, V> >::get_child(gsize index) const
{
Variant< std::pair<K, V> > dict_entry;
- VariantContainerBase::get(dict_entry, index);
+ VariantContainerBase::get_child(dict_entry, index);
return dict_entry.get();
}
diff --git a/tests/glibmm_variant/main.cc b/tests/glibmm_variant/main.cc
index efc151f0..816406e0 100644
--- a/tests/glibmm_variant/main.cc
+++ b/tests/glibmm_variant/main.cc
@@ -43,7 +43,7 @@ int main(int, char**)
unsigned index = 4;
ostr << "Element number " << index + 1 << " in the copy is " <<
- integers_variant.get(index) << '.' << std::endl;
+ integers_variant.get_child(index) << '.' << std::endl;
ostr << std::endl;
@@ -95,7 +95,7 @@ int main(int, char**)
index = 3;
- std::pair<unsigned, Glib::ustring> a_pair = orig_dict_variant.get(index);
+ std::pair<unsigned, Glib::ustring> a_pair = orig_dict_variant.get_child(index);
ostr << "Element number " << index + 1 << " in the variant is: (" <<
a_pair.first << ", " << a_pair.second << ")." << std::endl;