1 // Generated by gmmproc 2.64.2 -- DO NOT MODIFY!
2
3
4 #include <glibmm.h>
5
6 #include <glibmm/variantdict.h>
7 #include <glibmm/private/variantdict_p.h>
8
9
10 /*
11 * Copyright 2014 The gtkmm Development Team
12 *
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; either
16 * version 2.1 of the License, or (at your option) any later version.
17 *
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
22 *
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
25 */
26
27 #include <glib.h>
28
29 namespace Glib
30 {
31
32 bool
lookup_value_variant(const Glib::ustring & key,const VariantType & expected_type,VariantBase & value) const33 VariantDict::lookup_value_variant(
34 const Glib::ustring& key, const VariantType& expected_type, VariantBase& value) const
35 {
36 GVariant* const g_value = g_variant_dict_lookup_value(
37 const_cast<GVariantDict*>(gobj()), key.c_str(), expected_type.gobj());
38 if (!g_value)
39 return false;
40
41 value.init(g_value); // g_value is already referenced.
42 return true;
43 }
44
45 } // namespace Glib
46
47 namespace
48 {
49 } // anonymous namespace
50
51
52 /* Why reinterpret_cast<VariantDict*>(gobject) is needed:
53 *
54 * A VariantDict instance is in fact always a GVariantDict instance.
55 * Unfortunately, GVariantDict cannot be a member of VariantDict,
56 * because it is an opaque struct. Also, the C interface does not provide
57 * any hooks to install a destroy notification handler, thus we cannot
58 * wrap it dynamically either.
59 *
60 * The cast works because VariantDict does not have any member data, and
61 * it is impossible to derive from it. This is ensured by using final on the
62 * class and by using = delete on the default constructor.
63 */
64
65 namespace Glib
66 {
67
wrap(GVariantDict * object,bool take_copy)68 Glib::RefPtr<Glib::VariantDict> wrap(GVariantDict* object, bool take_copy)
69 {
70 if(take_copy && object)
71 g_variant_dict_ref(object);
72
73 // See the comment at the top of this file, if you want to know why the cast works.
74 return Glib::RefPtr<Glib::VariantDict>(reinterpret_cast<Glib::VariantDict*>(object));
75 }
76
77 } // namespace Glib
78
79
80 namespace Glib
81 {
82
reference() const83 void VariantDict::reference() const
84 {
85 // See the comment at the top of this file, if you want to know why the cast works.
86 g_variant_dict_ref(reinterpret_cast<GVariantDict*>(const_cast<VariantDict*>(this)));
87 }
88
unreference() const89 void VariantDict::unreference() const
90 {
91 // See the comment at the top of this file, if you want to know why the cast works.
92 g_variant_dict_unref(reinterpret_cast<GVariantDict*>(const_cast<VariantDict*>(this)));
93 }
94
gobj()95 GVariantDict* VariantDict::gobj()
96 {
97 // See the comment at the top of this file, if you want to know why the cast works.
98 return reinterpret_cast<GVariantDict*>(this);
99 }
100
gobj() const101 const GVariantDict* VariantDict::gobj() const
102 {
103 // See the comment at the top of this file, if you want to know why the cast works.
104 return reinterpret_cast<const GVariantDict*>(this);
105 }
106
gobj_copy() const107 GVariantDict* VariantDict::gobj_copy() const
108 {
109 // See the comment at the top of this file, if you want to know why the cast works.
110 const auto gobject = reinterpret_cast<GVariantDict*>(const_cast<VariantDict*>(this));
111 g_variant_dict_ref(gobject);
112 return gobject;
113 }
114
115
create(const VariantBase & from_asv)116 Glib::RefPtr<VariantDict> VariantDict::create(const VariantBase& from_asv)
117 {
118 return Glib::wrap(g_variant_dict_new(const_cast<GVariant*>((from_asv).gobj())));
119 }
120
create()121 Glib::RefPtr<VariantDict> VariantDict::create()
122 {
123 return Glib::wrap(g_variant_dict_new(nullptr));
124 }
125
contains(const Glib::ustring & key) const126 bool VariantDict::contains(const Glib::ustring& key) const
127 {
128 return g_variant_dict_contains(const_cast<GVariantDict*>(gobj()), key.c_str());
129 }
130
insert_value_variant(const Glib::ustring & key,const VariantBase & value)131 void VariantDict::insert_value_variant(const Glib::ustring& key, const VariantBase& value)
132 {
133 g_variant_dict_insert_value(gobj(), key.c_str(), const_cast<GVariant*>((value).gobj()));
134 }
135
remove(const Glib::ustring & key)136 bool VariantDict::remove(const Glib::ustring& key)
137 {
138 return g_variant_dict_remove(gobj(), key.c_str());
139 }
140
clear()141 void VariantDict::clear()
142 {
143 g_variant_dict_clear(gobj());
144 }
145
146
147 } // namespace Glib
148
149
150