1 // Generated by gmmproc 2.64.2 -- DO NOT MODIFY!
2
3
4 #include <glibmm.h>
5
6 #include <glibmm/bytes.h>
7 #include <glibmm/private/bytes_p.h>
8
9
10 /* Copyright (C) 2012 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 Glib
27 {
28
29 Glib::RefPtr<Glib::Bytes>
create(gconstpointer data,gsize size)30 Bytes::create(gconstpointer data, gsize size)
31 {
32 GBytes* bytes = g_bytes_new(data, size);
33 return Glib::wrap(bytes);
34 }
35
36 } // namespace Glib
37
38 namespace
39 {
40 } // anonymous namespace
41
42
43 /* Why reinterpret_cast<Bytes*>(gobject) is needed:
44 *
45 * A Bytes instance is in fact always a GBytes instance.
46 * Unfortunately, GBytes cannot be a member of Bytes,
47 * because it is an opaque struct. Also, the C interface does not provide
48 * any hooks to install a destroy notification handler, thus we cannot
49 * wrap it dynamically either.
50 *
51 * The cast works because Bytes does not have any member data, and
52 * it is impossible to derive from it. This is ensured by using final on the
53 * class and by using = delete on the default constructor.
54 */
55
56 namespace Glib
57 {
58
wrap(GBytes * object,bool take_copy)59 Glib::RefPtr<Glib::Bytes> wrap(GBytes* object, bool take_copy)
60 {
61 if(take_copy && object)
62 g_bytes_ref(object);
63
64 // See the comment at the top of this file, if you want to know why the cast works.
65 return Glib::RefPtr<Glib::Bytes>(reinterpret_cast<Glib::Bytes*>(object));
66 }
67
68 } // namespace Glib
69
70
71 namespace Glib
72 {
73
reference() const74 void Bytes::reference() const
75 {
76 // See the comment at the top of this file, if you want to know why the cast works.
77 g_bytes_ref(reinterpret_cast<GBytes*>(const_cast<Bytes*>(this)));
78 }
79
unreference() const80 void Bytes::unreference() const
81 {
82 // See the comment at the top of this file, if you want to know why the cast works.
83 g_bytes_unref(reinterpret_cast<GBytes*>(const_cast<Bytes*>(this)));
84 }
85
gobj()86 GBytes* Bytes::gobj()
87 {
88 // See the comment at the top of this file, if you want to know why the cast works.
89 return reinterpret_cast<GBytes*>(this);
90 }
91
gobj() const92 const GBytes* Bytes::gobj() const
93 {
94 // See the comment at the top of this file, if you want to know why the cast works.
95 return reinterpret_cast<const GBytes*>(this);
96 }
97
gobj_copy() const98 GBytes* Bytes::gobj_copy() const
99 {
100 // See the comment at the top of this file, if you want to know why the cast works.
101 const auto gobject = reinterpret_cast<GBytes*>(const_cast<Bytes*>(this));
102 g_bytes_ref(gobject);
103 return gobject;
104 }
105
106
get_data(gsize & size) const107 gconstpointer Bytes::get_data(gsize& size) const
108 {
109 return g_bytes_get_data(const_cast<GBytes*>(gobj()), &(size));
110 }
111
get_size() const112 gsize Bytes::get_size() const
113 {
114 return g_bytes_get_size(const_cast<GBytes*>(gobj()));
115 }
116
hash(gconstpointer bytes)117 guint Bytes::hash(gconstpointer bytes)
118 {
119 return g_bytes_hash(bytes);
120 }
121
equal(gconstpointer bytes1,gconstpointer bytes2)122 bool Bytes::equal(gconstpointer bytes1, gconstpointer bytes2)
123 {
124 return g_bytes_equal(bytes1, bytes2);
125 }
126
compare(gconstpointer bytes1,gconstpointer bytes2)127 gint Bytes::compare(gconstpointer bytes1, gconstpointer bytes2)
128 {
129 return g_bytes_compare(bytes1, bytes2);
130 }
131
132
133 } // namespace Glib
134
135
136