1 // Generated by gmmproc 2.64.2 -- DO NOT MODIFY!
2 
3 
4 #include <glibmm.h>
5 
6 #include <glibmm/bytearray.h>
7 #include <glibmm/private/bytearray_p.h>
8 
9 
10 /* Copyright (C) 2013 The glibmm Development Team
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public
14  * License as published by the Free Software Foundation; either
15  * version 2.1 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
24  */
25 
26 namespace
27 {
28 
29 extern "C" {
30 
31 int
ByteArray_Compare_Data_Func(gconstpointer a,gconstpointer b,gpointer user_data)32 ByteArray_Compare_Data_Func(gconstpointer a, gconstpointer b, gpointer user_data)
33 {
34   Glib::ByteArray::SlotCompare* slot = static_cast<Glib::ByteArray::SlotCompare*>(user_data);
35 
36   return (*slot)(static_cast<const guint8*>(a), static_cast<const guint8*>(b));
37 }
38 }
39 }
40 
41 namespace Glib
42 {
43 
44 guint
size() const45 ByteArray::size() const
46 {
47   return gobj()->len;
48 }
49 
50 guint8*
get_data()51 ByteArray::get_data()
52 {
53   return gobj()->data;
54 }
55 
56 const guint8*
get_data() const57 ByteArray::get_data() const
58 {
59   return gobj()->data;
60 }
61 
62 GType
get_type()63 ByteArray::get_type()
64 {
65   return g_byte_array_get_type();
66 }
67 
68 } // namespace Glib
69 
70 namespace
71 {
72 } // anonymous namespace
73 
74 
75 /* Why reinterpret_cast<ByteArray*>(gobject) is needed:
76  *
77  * A ByteArray instance is in fact always a GByteArray instance.
78  * Unfortunately, GByteArray cannot be a member of ByteArray,
79  * because it is an opaque struct.  Also, the C interface does not provide
80  * any hooks to install a destroy notification handler, thus we cannot
81  * wrap it dynamically either.
82  *
83  * The cast works because ByteArray does not have any member data, and
84  * it is impossible to derive from it.  This is ensured by using final on the
85  * class and by using = delete on the default constructor.
86  */
87 
88 namespace Glib
89 {
90 
wrap(GByteArray * object,bool take_copy)91 Glib::RefPtr<Glib::ByteArray> wrap(GByteArray* object, bool take_copy)
92 {
93   if(take_copy && object)
94     g_byte_array_ref(object);
95 
96   // See the comment at the top of this file, if you want to know why the cast works.
97   return Glib::RefPtr<Glib::ByteArray>(reinterpret_cast<Glib::ByteArray*>(object));
98 }
99 
100 } // namespace Glib
101 
102 
103 namespace Glib
104 {
105 
reference() const106 void ByteArray::reference() const
107 {
108   // See the comment at the top of this file, if you want to know why the cast works.
109   g_byte_array_ref(reinterpret_cast<GByteArray*>(const_cast<ByteArray*>(this)));
110 }
111 
unreference() const112 void ByteArray::unreference() const
113 {
114   // See the comment at the top of this file, if you want to know why the cast works.
115   g_byte_array_unref(reinterpret_cast<GByteArray*>(const_cast<ByteArray*>(this)));
116 }
117 
gobj()118 GByteArray* ByteArray::gobj()
119 {
120   // See the comment at the top of this file, if you want to know why the cast works.
121   return reinterpret_cast<GByteArray*>(this);
122 }
123 
gobj() const124 const GByteArray* ByteArray::gobj() const
125 {
126   // See the comment at the top of this file, if you want to know why the cast works.
127   return reinterpret_cast<const GByteArray*>(this);
128 }
129 
gobj_copy() const130 GByteArray* ByteArray::gobj_copy() const
131 {
132   // See the comment at the top of this file, if you want to know why the cast works.
133   const auto gobject = reinterpret_cast<GByteArray*>(const_cast<ByteArray*>(this));
134   g_byte_array_ref(gobject);
135   return gobject;
136 }
137 
138 
create()139 Glib::RefPtr<ByteArray> ByteArray::create()
140 {
141   return Glib::wrap(g_byte_array_new());
142 }
143 
append(const guint8 * data,guint len)144 Glib::RefPtr<ByteArray> ByteArray::append(const guint8* data, guint len)
145 {
146   Glib::RefPtr<ByteArray> retvalue = Glib::wrap(g_byte_array_append(gobj(), data, len));
147   if(retvalue)
148     retvalue->reference(); //The function does not do a ref for us.
149   return retvalue;
150 }
151 
prepend(const guint8 * data,guint len)152 Glib::RefPtr<ByteArray> ByteArray::prepend(const guint8* data, guint len)
153 {
154   Glib::RefPtr<ByteArray> retvalue = Glib::wrap(g_byte_array_prepend(gobj(), data, len));
155   if(retvalue)
156     retvalue->reference(); //The function does not do a ref for us.
157   return retvalue;
158 }
159 
remove_index(guint index)160 Glib::RefPtr<ByteArray> ByteArray::remove_index(guint index)
161 {
162   Glib::RefPtr<ByteArray> retvalue = Glib::wrap(g_byte_array_remove_index(gobj(), index));
163   if(retvalue)
164     retvalue->reference(); //The function does not do a ref for us.
165   return retvalue;
166 }
167 
remove_index_fast(guint index)168 Glib::RefPtr<ByteArray> ByteArray::remove_index_fast(guint index)
169 {
170   Glib::RefPtr<ByteArray> retvalue = Glib::wrap(g_byte_array_remove_index_fast(gobj(), index));
171   if(retvalue)
172     retvalue->reference(); //The function does not do a ref for us.
173   return retvalue;
174 }
175 
remove_range(guint index,guint length)176 Glib::RefPtr<ByteArray> ByteArray::remove_range(guint index, guint length)
177 {
178   Glib::RefPtr<ByteArray> retvalue = Glib::wrap(g_byte_array_remove_range(gobj(), index, length));
179   if(retvalue)
180     retvalue->reference(); //The function does not do a ref for us.
181   return retvalue;
182 }
183 
sort(const SlotCompare & slot)184 void ByteArray::sort(const SlotCompare& slot)
185 {
186   // Use the original slot (not a copy).
187   auto slot_copy = const_cast<SlotCompare*>(&slot);
188 
189   g_byte_array_sort_with_data(gobj(), &ByteArray_Compare_Data_Func, slot_copy);
190 }
191 
set_size(guint length)192 Glib::RefPtr<ByteArray> ByteArray::set_size(guint length)
193 {
194   Glib::RefPtr<ByteArray> retvalue = Glib::wrap(g_byte_array_set_size(gobj(), length));
195   if(retvalue)
196     retvalue->reference(); //The function does not do a ref for us.
197   return retvalue;
198 }
199 
200 
201 } // namespace Glib
202 
203 
204