1 // Generated by gmmproc 2.64.2 -- DO NOT MODIFY!
2 
3 
4 #include <glibmm.h>
5 
6 #include <glibmm/variantiter.h>
7 #include <glibmm/private/variantiter_p.h>
8 
9 
10 /* Copyright(C) 2010 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 #include <glibmm/variant.h>
27 #include <glib.h>
28 
29 namespace Glib
30 {
31 
VariantIter(const VariantBase & variant)32 VariantIter::VariantIter(const VariantBase& variant)
33 : gobject_(g_variant_iter_new(const_cast<GVariant*>(variant.gobj())))
34 {
35 }
36 
37 bool
next_value(VariantBase & value)38 VariantIter::next_value(VariantBase& value)
39 {
40   GVariant* const g_value = g_variant_iter_next_value(gobj());
41 
42   if (g_value)
43   {
44     value.init(g_value); // g_value is already referenced.
45     return true;
46   }
47   else
48     return false;
49 }
50 
51 } // namespace Glib
52 
53 namespace
54 {
55 } // anonymous namespace
56 
57 
58 namespace Glib
59 {
60 
wrap(GVariantIter * object,bool take_copy)61 Glib::VariantIter wrap(GVariantIter* object, bool take_copy /* = false */)
62 {
63   return Glib::VariantIter(object, take_copy);
64 }
65 
66 } // namespace Glib
67 
68 
69 namespace Glib
70 {
71 
72 
VariantIter()73 VariantIter::VariantIter()
74 :
75   gobject_ (nullptr) // Allows creation of invalid wrapper, e.g. for output arguments to methods.
76 {}
77 
VariantIter(const VariantIter & src)78 VariantIter::VariantIter(const VariantIter& src)
79 :
80   gobject_ ((src.gobject_) ? g_variant_iter_copy(src.gobject_) : nullptr)
81 {}
82 
VariantIter(GVariantIter * castitem,bool make_a_copy)83 VariantIter::VariantIter(GVariantIter* castitem, bool make_a_copy /* = false */)
84 {
85   if(!make_a_copy)
86   {
87     // It was given to us by a function which has already made a copy for us to keep.
88     gobject_ = castitem;
89   }
90   else
91   {
92     // We are probably getting it via direct access to a struct,
93     // so we can not just take it - we have to take a copy of it.
94     if(castitem)
95       gobject_ = g_variant_iter_copy(castitem);
96     else
97       gobject_ = nullptr;
98   }
99 }
100 
101 
operator =(const VariantIter & src)102 VariantIter& VariantIter::operator=(const VariantIter& src)
103 {
104   const auto new_gobject = (src.gobject_) ? g_variant_iter_copy(src.gobject_) : nullptr;
105 
106   if(gobject_)
107     g_variant_iter_free(gobject_);
108 
109   gobject_ = new_gobject;
110 
111   return *this;
112 }
113 
VariantIter(VariantIter && other)114 VariantIter::VariantIter(VariantIter&& other) noexcept
115 :
116   gobject_(other.gobject_)
117 {
118   other.gobject_ = nullptr;
119 }
120 
operator =(VariantIter && other)121 VariantIter& VariantIter::operator=(VariantIter&& other) noexcept
122 {
123   VariantIter temp (other);
124   swap(temp);
125   return *this;
126 }
127 
~VariantIter()128 VariantIter::~VariantIter() noexcept
129 {
130   if(gobject_)
131     g_variant_iter_free(gobject_);
132 }
133 
swap(VariantIter & other)134 void VariantIter::swap(VariantIter& other) noexcept
135 {
136   std::swap(gobject_, other.gobject_);
137 }
138 
gobj_copy() const139 GVariantIter* VariantIter::gobj_copy() const
140 {
141   return g_variant_iter_copy(gobject_);
142 }
143 
144 
init(const VariantContainerBase & value)145 gsize VariantIter::init(const VariantContainerBase& value)
146 {
147   return g_variant_iter_init(gobj(), const_cast<GVariant*>((value).gobj()));
148 }
149 
get_n_children() const150 gsize VariantIter::get_n_children() const
151 {
152   return g_variant_iter_n_children(const_cast<GVariantIter*>(gobj()));
153 }
154 
155 
156 } // namespace Glib
157 
158 
159