More gracefully handle type mismatch errors when doing playlist things (just ignore...
[ardour.git] / libs / glibmm2 / glib / src / optionentry.ccg
1 // -*- c++ -*-
2 /* $Id: optionentry.ccg,v 1.8 2006/03/08 12:23:03 murrayc Exp $ */
3
4 /* Copyright (C) 2002 The gtkmm Development Team
5  *
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.
10  *
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.
15  *
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.
19  */
20
21 #include <glibmm/utility.h>
22 #include <glib/goption.h>
23 #include <glib/gmem.h>
24
25 namespace Glib
26 {
27
28 OptionEntry::OptionEntry()
29 {
30   gobject_ = g_new0(GOptionEntry, 1);
31 }
32
33 OptionEntry::~OptionEntry()
34 {
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));
38   g_free(gobject_);  
39 }
40
41 OptionEntry::OptionEntry(const OptionEntry& src)
42 {
43   gobject_ = g_new0(GOptionEntry, 1);
44
45   operator=(src);
46 }
47
48 OptionEntry& OptionEntry::operator=(const OptionEntry& src)
49 {
50   if(this != &src)
51   {
52     if(gobject_->long_name)
53       g_free(const_cast<char*>(gobject_->long_name));
54
55     gobject_->long_name = g_strdup(src.gobject_->long_name);
56
57     gobject_->short_name = src.gobject_->short_name; //It's just one char.
58
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.
62
63     if(gobject_->description)
64       g_free(const_cast<char*>(gobject_->description));    
65
66     gobject_->description = g_strdup(src.gobject_->description);
67
68     if(gobject_->arg_description)
69       g_free(const_cast<char*>(gobject_->arg_description));
70
71     gobject_->arg_description = g_strdup(src.gobject_->arg_description);
72   }
73
74   return *this;
75 }
76
77
78 } // namespace Glib
79