summaryrefslogtreecommitdiff
path: root/glib
diff options
context:
space:
mode:
authorJosé Alburquerque <jaalburqu@svn.gnome.org>2013-04-12 00:01:02 -0400
committerJosé Alburquerque <jaalburqu@svn.gnome.org>2013-04-12 00:01:02 -0400
commitf87fc0ed78cd7e306a617fcd83208ad90395a7b1 (patch)
tree92cbbc3c3f4d952051edef63b657f1d7f73f9012 /glib
parent975f517d1adf53c4c6df96fca524141c3638d92a (diff)
downloadglibmm-f87fc0ed78cd7e306a617fcd83208ad90395a7b1.tar.gz
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.
Diffstat (limited to 'glib')
-rw-r--r--glib/src/bytearray.ccg10
-rw-r--r--glib/src/bytearray.hg16
2 files changed, 21 insertions, 5 deletions
diff --git a/glib/src/bytearray.ccg b/glib/src/bytearray.ccg
index db3585ff..f2a0158b 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 a9e2312b..cea6f6d6 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)