[glibmm/glibmm-2-36] ByteArray: Add size() and get_data() methods.



commit eb635f12da6eb17cf423383dc9e8f23144f41be3
Author: José Alburquerque <jaalburqu svn gnome org>
Date:   Fri Apr 12 00:01:02 2013 -0400

    ByteArray: Add size() and get_data() methods.
    
        * glib/src/bytearray.{ccg,hg}:  Add these methods so that accessing
        the underlying GByteArray's data and len members (which is how it is
        done in the C API) is just as easy with glibmm.  Also use _WRAP_METHOD
        to wrap the create() method.

 ChangeLog              |  9 +++++++++
 glib/src/bytearray.ccg | 10 +++++++---
 glib/src/bytearray.hg  | 16 ++++++++++++++--
 3 files changed, 30 insertions(+), 5 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 48ff8a6..bd123d0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2013-04-11  José Alburquerque  <jaalburquerque gmail com>
+
+       ByteArray: Add size() and get_data() methods.
+
+       * glib/src/bytearray.{ccg,hg}:  Add these methods so that accessing
+       the underlying GByteArray's data and len members (which is how it is
+       done in the C API) is just as easy with glibmm.  Also use _WRAP_METHOD
+       to wrap the create() method.
+
 2013-04-09  José Alburquerque  <jaalburquerque gmail com>
 
        gmmproc: Parse the argument list of methods correctly.
diff --git a/glib/src/bytearray.ccg b/glib/src/bytearray.ccg
index db3585f..f2a0158 100644
--- a/glib/src/bytearray.ccg
+++ b/glib/src/bytearray.ccg
@@ -37,10 +37,14 @@ int ByteArray_Compare_Data_Func(gconstpointer a, gconstpointer b,
 namespace Glib
 {
 
-Glib::RefPtr<Glib::ByteArray> ByteArray::create()
+guint ByteArray::size() const
 {
-  GByteArray* array = g_byte_array_new();
-  return Glib::wrap(array);
+  return gobj()->len;
+}
+
+guint8* ByteArray::get_data() const
+{
+  return gobj()->data;
 }
 
 GType ByteArray::get_type()
diff --git a/glib/src/bytearray.hg b/glib/src/bytearray.hg
index a9e2312..cea6f6d 100644
--- a/glib/src/bytearray.hg
+++ b/glib/src/bytearray.hg
@@ -53,11 +53,23 @@ public:
    */
   typedef sigc::slot<int, const guint8*, const guint8*> SlotCompare;
 
-  _WRAP_METHOD_DOCS_ONLY(g_byte_array_new)
-  static Glib::RefPtr<Glib::ByteArray> create();
+  _WRAP_METHOD(static Glib::RefPtr<ByteArray> create(), g_byte_array_new)
 
   _WRAP_METHOD(Glib::RefPtr<ByteArray> append(const guint8* data, guint len), g_byte_array_append)
   _WRAP_METHOD(Glib::RefPtr<ByteArray> prepend(const guint8* data, guint len), g_byte_array_prepend)
+
+  /** Gets the size of the byte array.
+   * @return The size.
+   * @newin{2,36}
+   */
+  guint size() const;
+
+  /** Gets the data of the byte array.
+   * @return The data.
+   * @newin{2,36}
+   */
+  guint8* get_data() const;
+
   _WRAP_METHOD(Glib::RefPtr<ByteArray> remove_index(guint index_), g_byte_array_remove_index)
   _WRAP_METHOD(Glib::RefPtr<ByteArray> remove_index_fast(guint index_), g_byte_array_remove_index_fast)
   _WRAP_METHOD(Glib::RefPtr<ByteArray> remove_range(guint index_, guint length), g_byte_array_remove_range)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]