1 // Generated by gmmproc 2.64.2 -- DO NOT MODIFY!
2
3 #undef G_DISABLE_DEPRECATED
4 #define GLIB_DISABLE_DEPRECATION_WARNINGS 1
5
6 #include <glibmmconfig.h>
7 #ifndef GLIBMM_DISABLE_DEPRECATED
8
9
10 #include <glibmm.h>
11
12 #include <glibmm/valuearray.h>
13 #include <glibmm/private/valuearray_p.h>
14
15
16 /* Copyright (C) 2002-2009 The gtkmm Development Team
17 *
18 * This library is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU Lesser General Public
20 * License as published by the Free Software Foundation; either
21 * version 2.1 of the License, or (at your option) any later version.
22 *
23 * This library is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 * Lesser General Public License for more details.
27 *
28 * You should have received a copy of the GNU Lesser General Public
29 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
30 */
31
32 #include <glibmm/exceptionhandler.h>
33
34 static int
ValueArray_Compare_glibmm_callback(gconstpointer a,gconstpointer b,gpointer user_data)35 ValueArray_Compare_glibmm_callback(gconstpointer a, gconstpointer b, gpointer user_data)
36 {
37 Glib::ValueArray::SlotCompare* the_slot = static_cast<Glib::ValueArray::SlotCompare*>(user_data);
38
39 try
40 {
41 return (*the_slot)(
42 *reinterpret_cast<const Glib::ValueBase*>(a), *reinterpret_cast<const Glib::ValueBase*>(b));
43 }
44 catch (...)
45 {
46 Glib::exception_handlers_invoke();
47 }
48
49 return 0;
50 }
51
52 namespace Glib
53 {
54
ValueArray()55 ValueArray::ValueArray() : gobject_(g_value_array_new(0))
56 {
57 }
58
ValueArray(guint n_preallocated)59 ValueArray::ValueArray(guint n_preallocated) : gobject_(g_value_array_new(n_preallocated))
60 {
61 }
62
63 bool
get_nth(guint index,Glib::ValueBase & value)64 ValueArray::get_nth(guint index, Glib::ValueBase& value)
65 {
66 const auto g_value = g_value_array_get_nth(gobj(), index);
67
68 if (g_value)
69 {
70 value.init(g_value);
71 return true;
72 }
73 else
74 return false;
75 }
76
77 Glib::ValueArray&
append(const Glib::ValueBase & value)78 ValueArray::append(const Glib::ValueBase& value)
79 {
80 g_value_array_append(gobj(), value.gobj());
81 return *this;
82 }
83
84 Glib::ValueArray&
prepend(const Glib::ValueBase & value)85 ValueArray::prepend(const Glib::ValueBase& value)
86 {
87 g_value_array_prepend(gobj(), value.gobj());
88 return *this;
89 }
90
91 Glib::ValueArray&
insert(guint index,const Glib::ValueBase & value)92 ValueArray::insert(guint index, const Glib::ValueBase& value)
93 {
94 g_value_array_insert(gobj(), index, value.gobj());
95 return *this;
96 }
97
98 Glib::ValueArray&
remove(guint index)99 ValueArray::remove(guint index)
100 {
101 g_value_array_remove(gobj(), index);
102 return *this;
103 }
104
105 Glib::ValueArray&
sort(const SlotCompare & compare_func)106 ValueArray::sort(const SlotCompare& compare_func)
107 {
108 SlotCompare slot_copy(compare_func);
109 g_value_array_sort_with_data(gobj(), &ValueArray_Compare_glibmm_callback, &slot_copy);
110 return *this;
111 }
112
113 } // Glib namespace
114
115 namespace
116 {
117 } // anonymous namespace
118
119
120 namespace Glib
121 {
122
wrap(GValueArray * object,bool take_copy)123 Glib::ValueArray wrap(GValueArray* object, bool take_copy)
124 {
125 return Glib::ValueArray(object, take_copy);
126 }
127
128 } // namespace Glib
129
130
131 namespace Glib
132 {
133
134
135 // static
get_type()136 GType ValueArray::get_type()
137 {
138 return g_value_array_get_type();
139 }
140
141
ValueArray(const ValueArray & other)142 ValueArray::ValueArray(const ValueArray& other)
143 :
144 gobject_ ((other.gobject_) ? g_value_array_copy(other.gobject_) : nullptr)
145 {}
146
ValueArray(ValueArray && other)147 ValueArray::ValueArray(ValueArray&& other) noexcept
148 :
149 gobject_(other.gobject_)
150 {
151 other.gobject_ = nullptr;
152 }
153
operator =(ValueArray && other)154 ValueArray& ValueArray::operator=(ValueArray&& other) noexcept
155 {
156 ValueArray temp (other);
157 swap(temp);
158 return *this;
159 }
160
ValueArray(GValueArray * gobject,bool make_a_copy)161 ValueArray::ValueArray(GValueArray* gobject, bool make_a_copy)
162 :
163 // For BoxedType wrappers, make_a_copy is true by default. The static
164 // BoxedType wrappers must always take a copy, thus make_a_copy = true
165 // ensures identical behaviour if the default argument is used.
166 gobject_ ((make_a_copy && gobject) ? g_value_array_copy(gobject) : gobject)
167 {}
168
operator =(const ValueArray & other)169 ValueArray& ValueArray::operator=(const ValueArray& other)
170 {
171 ValueArray temp (other);
172 swap(temp);
173 return *this;
174 }
175
~ValueArray()176 ValueArray::~ValueArray() noexcept
177 {
178 if(gobject_)
179 g_value_array_free(gobject_);
180 }
181
swap(ValueArray & other)182 void ValueArray::swap(ValueArray& other) noexcept
183 {
184 std::swap(gobject_, other.gobject_);
185 }
186
gobj_copy() const187 GValueArray* ValueArray::gobj_copy() const
188 {
189 return g_value_array_copy(gobject_);
190 }
191
192
193 } // namespace Glib
194
195
196 #endif // GLIBMM_DISABLE_DEPRECATED
197
198
199