1 // Generated by gmmproc 2.64.2 -- DO NOT MODIFY! 2 3 4 #include <glibmm.h> 5 6 #include <glibmm/optionentry.h> 7 #include <glibmm/private/optionentry_p.h> 8 9 10 /* Copyright (C) 2002 The gtkmm 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/utility.h> 27 #include <glib.h> 28 29 namespace Glib 30 { 31 OptionEntry()32OptionEntry::OptionEntry() 33 { 34 gobject_ = g_new0(GOptionEntry, 1); 35 } 36 ~OptionEntry()37OptionEntry::~OptionEntry() 38 { 39 release_gobject(); 40 } 41 42 void release_gobject()43OptionEntry::release_gobject() noexcept 44 { 45 if (!gobject_) 46 return; 47 48 g_free(const_cast<char*>(gobject_->long_name)); 49 g_free(const_cast<char*>(gobject_->description)); 50 g_free(const_cast<char*>(gobject_->arg_description)); 51 g_free(gobject_); 52 } 53 OptionEntry(const OptionEntry & src)54OptionEntry::OptionEntry(const OptionEntry& src) 55 { 56 gobject_ = g_new0(GOptionEntry, 1); 57 58 operator=(src); 59 } 60 61 OptionEntry& operator =(const OptionEntry & src)62OptionEntry::operator=(const OptionEntry& src) 63 { 64 if (this != &src) 65 { 66 if (gobject_->long_name) 67 g_free(const_cast<char*>(gobject_->long_name)); 68 69 gobject_->long_name = g_strdup(src.gobject_->long_name); 70 71 gobject_->short_name = src.gobject_->short_name; // It's just one char. 72 73 gobject_->flags = src.gobject_->flags; 74 gobject_->arg = src.gobject_->arg; 75 gobject_->arg_data = 76 src.gobject_ 77 ->arg_data; // Shared, because it's not owned by any instance of this class anyway. 78 79 if (gobject_->description) 80 g_free(const_cast<char*>(gobject_->description)); 81 82 gobject_->description = g_strdup(src.gobject_->description); 83 84 if (gobject_->arg_description) 85 g_free(const_cast<char*>(gobject_->arg_description)); 86 87 gobject_->arg_description = g_strdup(src.gobject_->arg_description); 88 } 89 90 return *this; 91 } 92 OptionEntry(OptionEntry && other)93OptionEntry::OptionEntry(OptionEntry&& other) noexcept : gobject_(std::move(other.gobject_)) 94 { 95 other.gobject_ = nullptr; 96 } 97 98 OptionEntry& operator =(OptionEntry && other)99OptionEntry::operator=(OptionEntry&& other) noexcept 100 { 101 release_gobject(); 102 103 gobject_ = std::move(other.gobject_); 104 other.gobject_ = nullptr; 105 106 return *this; 107 } 108 109 void set_long_name(const Glib::ustring & value)110OptionEntry::set_long_name(const Glib::ustring& value) 111 { 112 if (gobject_->long_name) 113 { 114 g_free((gchar*)(gobject_->long_name)); 115 gobject_->long_name = nullptr; 116 } 117 118 // Note that we do not use nullptr for an empty string, 119 // because G_OPTION_REMAINING is actually a "", so it actually has a distinct meaning: 120 // TODO: Wrap G_OPTION_REMAINING in C++ somehow, maybe as an explicit set_long_name(void) or 121 // set_is_remaining()? murrayc. 122 gobj()->long_name = (value).c_str() ? g_strdup((value).c_str()) : nullptr; 123 } 124 125 void set_description(const Glib::ustring & value)126OptionEntry::set_description(const Glib::ustring& value) 127 { 128 if (gobject_->description) 129 { 130 g_free((gchar*)(gobject_->description)); 131 gobject_->description = nullptr; 132 } 133 134 gobj()->description = (value).empty() ? nullptr : g_strdup((value).c_str()); 135 } 136 137 void set_arg_description(const Glib::ustring & value)138OptionEntry::set_arg_description(const Glib::ustring& value) 139 { 140 if (gobject_->arg_description) 141 { 142 g_free((gchar*)(gobject_->arg_description)); 143 gobject_->arg_description = nullptr; 144 } 145 146 gobj()->arg_description = (value).empty() ? nullptr : g_strdup((value).c_str()); 147 } 148 149 } // namespace Glib 150 151 namespace 152 { 153 } // anonymous namespace 154 155 156 namespace Glib 157 { 158 159 get_long_name() const160Glib::ustring OptionEntry::get_long_name() const 161 { 162 return Glib::convert_const_gchar_ptr_to_ustring(gobj()->long_name); 163 } 164 get_short_name() const165gchar OptionEntry::get_short_name() const 166 { 167 return gobj()->short_name; 168 } 169 set_short_name(const gchar & value)170void OptionEntry::set_short_name(const gchar& value) 171 { 172 gobj()->short_name = value; 173 } 174 get_flags() const175int OptionEntry::get_flags() const 176 { 177 return gobj()->flags; 178 } 179 set_flags(const int & value)180void OptionEntry::set_flags(const int& value) 181 { 182 gobj()->flags = value; 183 } 184 get_description() const185Glib::ustring OptionEntry::get_description() const 186 { 187 return Glib::convert_const_gchar_ptr_to_ustring(gobj()->description); 188 } 189 get_arg_description() const190Glib::ustring OptionEntry::get_arg_description() const 191 { 192 return Glib::convert_const_gchar_ptr_to_ustring(gobj()->arg_description); 193 } 194 195 196 } // namespace Glib 197 198 199