2 /* $Id: optionentry.ccg,v 1.8 2006/03/08 12:23:03 murrayc Exp $ */
4 /* Copyright (C) 2002 The gtkmm Development Team
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the Free
18 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <glibmm/utility.h>
22 #include <glib/goption.h>
23 #include <glib/gmem.h>
28 OptionEntry::OptionEntry()
30 gobject_ = g_new0(GOptionEntry, 1);
33 OptionEntry::~OptionEntry()
35 g_free(const_cast<char*>(gobject_->long_name));
36 g_free(const_cast<char*>(gobject_->description));
37 g_free(const_cast<char*>(gobject_->arg_description));
41 OptionEntry::OptionEntry(const OptionEntry& src)
43 gobject_ = g_new0(GOptionEntry, 1);
48 OptionEntry& OptionEntry::operator=(const OptionEntry& src)
52 if(gobject_->long_name)
53 g_free(const_cast<char*>(gobject_->long_name));
55 gobject_->long_name = g_strdup(src.gobject_->long_name);
57 gobject_->short_name = src.gobject_->short_name; //It's just one char.
59 gobject_->flags = src.gobject_->flags;
60 gobject_->arg = src.gobject_->arg;
61 gobject_->arg_data = src.gobject_->arg_data; //Shared, because it's not owned by any instance of this class anyway.
63 if(gobject_->description)
64 g_free(const_cast<char*>(gobject_->description));
66 gobject_->description = g_strdup(src.gobject_->description);
68 if(gobject_->arg_description)
69 g_free(const_cast<char*>(gobject_->arg_description));
71 gobject_->arg_description = g_strdup(src.gobject_->arg_description);