diff options
author | Murray Cumming <murrayc@murrayc.com> | 2010-09-13 09:43:48 +0200 |
---|---|---|
committer | Murray Cumming <murrayc@murrayc.com> | 2010-09-13 09:43:48 +0200 |
commit | e1ca0fedb49a00eb3c739866cc23df9966a5bee8 (patch) | |
tree | 3238ea7e96e77b33c5d435eadb369ff42535607b | |
parent | dd26647989b7706b967fc912d4e12bab82a42654 (diff) | |
download | glibmm-e1ca0fedb49a00eb3c739866cc23df9966a5bee8.tar.gz |
Variant: Added some methods.
* glib/src/variant.[hg|ccg]: Added get_maybe(), get_size(), get_data(),
store(), and get_n_children().
-rw-r--r-- | ChangeLog | 25 | ||||
-rw-r--r-- | glib/src/variant.ccg | 17 | ||||
-rw-r--r-- | glib/src/variant.hg | 23 |
3 files changed, 50 insertions, 15 deletions
@@ -1,3 +1,10 @@ +2010-09-13 Murray Cumming <murrayc@murrayc.com> + + Variant: Added some methods. + + * glib/src/variant.[hg|ccg]: Added get_maybe(), get_size(), get_data(), + store(), and get_n_children(). + 2010-09-09 José Alburquerque <jaalburqu@svn.gnome.org> giomm: DBus: Wrap D-Bus Utilities and GDBusError C functions. @@ -22,7 +29,7 @@ returning a const GDBusMethodInfo. * tools/m4/convert_gio.m4: Move the conversion DBusMethodInvocation::get_method_info() over to the local .hg file - because it is specific to that method. + because it is specific to that method. 2010-09-07 José Alburquerque <jaalburqu@svn.gnome.org> @@ -77,20 +84,20 @@ gmmproc: Fix the annoying warnings about documentation. - * tools/pm/GtkDefs.pm: lookup_object(): Do not print a warning when the - object is found, because this is used when guessing an object name while + * tools/pm/GtkDefs.pm: lookup_object(): Do not print a warning when the + object is found, because this is used when guessing an object name while breaking apart a function name in DocsParser.pm. * gio/src/filelist.am: * gio/src/gio.defs: * gio/src/gio_extra_objects.defs: * glib/src/filelist.am: * glib/src/glib.defs: - * glib/src/glib_extra_objects.defs: Added the *extra_objects.defs files, + * glib/src/glib_extra_objects.defs: Added the *extra_objects.defs files, with hand-coded define-object sections, for objects that hide their *Class - or *Iface struct declarations, which stops h2defs.py from generating + or *Iface struct declarations, which stops h2defs.py from generating define-object sections. - These allows DocsParser.pm to know how to split mentions of C functions into - the object and the method, so it can guess the C++ method name to mention + These allows DocsParser.pm to know how to split mentions of C functions into + the object and the method, so it can guess the C++ method name to mention instead. 2010-09-03 Murray Cumming <murrayc@murrayc.com> @@ -120,8 +127,8 @@ giomm: Added Proxy, ProxyAddress and ProxyResolver. - * gio/src/proxy.[hg|ccg]: - * gio/src/proxyaddress.[hg|ccg]: + * gio/src/proxy.[hg|ccg]: + * gio/src/proxyaddress.[hg|ccg]: * gio/src/proxyresolver.[hg|ccg]: New files, not complete. 2.25.4: diff --git a/glib/src/variant.ccg b/glib/src/variant.ccg index c30275af..f7808ace 100644 --- a/glib/src/variant.ccg +++ b/glib/src/variant.ccg @@ -27,6 +27,8 @@ void VariantBase::get_normal_form(VariantBase& result) const GVariant* const g_value = g_variant_get_normal_form(const_cast<GVariant*>(gobj())); + //The C function never returns NULL, according to its docuemenation, + //so we don't need a bool return value. result.init(g_value); // g_value is already referenced. } @@ -36,6 +38,21 @@ void VariantBase::byteswap(VariantBase& result) const result.init(g_value); // g_value is already referenced. } +bool VariantBase::get_maybe(Glib::VariantBase& maybe) const +{ + GVariant* const g_value = + g_variant_get_maybe(const_cast<GVariant*>(gobj())); + + if(g_value) + { + maybe.init(g_value); // g_value is already referenced. + return true; + } + else + return false; +} + + /****************** Specializations ***********************************/ diff --git a/glib/src/variant.hg b/glib/src/variant.hg index 615d2747..7ee6d236 100644 --- a/glib/src/variant.hg +++ b/glib/src/variant.hg @@ -59,10 +59,20 @@ public: _WRAP_METHOD(bool is_of_type(const VariantType& type) const, g_variant_is_of_type) _WRAP_METHOD(bool is_container() const, g_variant_is_container) _WRAP_METHOD(GVariantClass classify() const, g_variant_classify) - + + bool get_maybe(Glib::VariantBase& maybe) const; + _IGNORE(g_variant_get_maybe) + + //TODO: Somehow put this method only in specializations that use container types?: + _WRAP_METHOD(gsize get_n_children() const, g_variant_n_children) + + _WRAP_METHOD(gsize get_size() const, g_variant_get_size) + _WRAP_METHOD(gconstpointer get_data(), g_variant_get_data) + _WRAP_METHOD(void store(gpointer data) const, g_variant_store) + _WRAP_METHOD(Glib::ustring print(bool type_annotate = false) const, g_variant_print) _IGNORE(g_variant_print_string) - + #m4 _CONVERSION(`const VariantBase&',`gconstpointer',`const_cast<GVariant*>(($3).gobj())') _WRAP_METHOD(guint hash() const, g_variant_hash) _WRAP_METHOD(bool equal(const VariantBase& other) const, g_variant_equal) @@ -142,11 +152,11 @@ public: Variant<VariantBase>() : VariantBase() {} - + explicit Variant<VariantBase>(GVariant* castitem) : VariantBase(castitem) {} - + static const GVariantType* variant_type() G_GNUC_CONST; //This must have a create() method because otherwise it would be a copy constructor. @@ -170,11 +180,11 @@ public: Variant<Glib::ustring>() : VariantBase() {} - + explicit Variant<Glib::ustring>(GVariant* castitem) : VariantBase(castitem) {} - + static const GVariantType* variant_type() G_GNUC_CONST; static Variant<Glib::ustring> create(const Glib::ustring& data); @@ -185,6 +195,7 @@ public: } // namespace Glib +//We ignore g_variant_get_*() methods that are wrapped by Variant<> specializations, such as in variant_basictypes.h.m4. _IGNORE( g_variant_get_boolean, g_variant_get_uint16, |