rollback to 3428, before the mysterious removal of libs/* at 3431/3432
[ardour.git] / libs / glibmm2 / glib / glibmm / optiongroup.h
1 // -*- c++ -*-
2 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #ifndef _GLIBMM_OPTIONGROUP_H
4 #define _GLIBMM_OPTIONGROUP_H
5
6
7 /* $Id: optiongroup.hg,v 1.10.4.1 2006/03/30 12:19:58 murrayc Exp $ */
8
9 /* Copyright (C) 2004 The glibmm Development Team
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Library General Public
13  * License as published by the Free Software Foundation; either
14  * version 2 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Library General Public License for more details.
20  *
21  * You should have received a copy of the GNU Library General Public
22  * License along with this library; if not, write to the Free
23  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24  */
25
26
27 #include <glibmm/ustring.h>
28 #include <map>
29 #include <vector>
30 #include <glib/goption.h> //TODO: Try to hide this.
31
32
33 #ifndef DOXYGEN_SHOULD_SKIP_THIS
34 extern "C" { typedef struct _GOptionGroup GOptionGroup; }
35 #endif //DOXYGEN_SHOULD_SKIP_THIS
36
37
38 namespace Glib
39 {
40
41 #ifndef DOXYGEN_SHOULD_SKIP_THIS
42 class OptionEntry;
43 class OptionContext;
44 #endif //DOXYGEN_SHOULD_SKIP_THIS
45
46 /** An OptionGroup defines the options in a single group. 
47  * Libraries which need to parse commandline options are expected to provide a function that allows their OptionGroups to
48  * be added to the application's OptionContext.
49  */
50 class OptionGroup
51 {
52   public:
53 #ifndef DOXYGEN_SHOULD_SKIP_THIS
54   typedef OptionGroup CppObjectType;
55   typedef GOptionGroup BaseObjectType;
56 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
57
58 private:
59
60 public:
61   OptionGroup(const Glib::ustring& name, const Glib::ustring& description, const Glib::ustring& help_description = Glib::ustring());
62
63   /** This always takes ownership of the underlying GOptionGroup, 
64    * so it is only useful with C functions that return newly-allocated GOptionGroups. 
65    */
66   explicit OptionGroup(GOptionGroup* castitem);  
67   
68   virtual ~OptionGroup();
69   
70
71   virtual bool on_pre_parse(OptionContext& context, OptionGroup& group);
72   virtual bool on_post_parse(OptionContext& context, OptionGroup& group);
73   virtual void on_error(OptionContext& context, OptionGroup& group);
74   
75
76   void add_entry(const OptionEntry& entry);
77   
78
79   typedef std::vector<Glib::ustring> vecustrings;
80   typedef std::vector<std::string> vecstrings;
81
82   void add_entry(const OptionEntry& entry, bool& arg);
83   void add_entry(const OptionEntry& entry, int& arg);
84   void add_entry(const OptionEntry& entry, Glib::ustring& arg);
85   void add_entry_filename(const OptionEntry& entry, std::string& arg);  
86   void add_entry(const OptionEntry& entry, vecustrings& arg);
87   void add_entry_filename(const OptionEntry& entry, vecstrings& arg);
88
89 /* TODO:
90 void          g_option_group_set_translate_func     (GOptionGroup       *group,
91                                                      GTranslateFunc      func,
92                                                      gpointer            data,
93                                                      GDestroyNotify      destroy_notify);
94 */
95   
96   /** A convenience function to use gettext() for translating
97    * user-visible strings. 
98    * 
99    * @newin2p6
100    * @param domain The domain to use.
101    */
102   void set_translation_domain(const Glib::ustring& domain);
103
104   GOptionGroup*       gobj()       { return gobject_; }
105   const GOptionGroup* gobj() const { return gobject_; }
106   GOptionGroup* gobj_give_ownership();
107
108 protected:
109
110 #ifndef DOXYGEN_SHOULD_SKIP_THIS
111   /** This is not public API. It is an implementation detail.
112    */
113   class CppOptionEntry
114   {
115   public:
116     CppOptionEntry();
117
118     void allocate_c_arg();
119     void set_c_arg_default(void* cpp_arg);
120     void convert_c_to_cpp();
121     void release_c_arg();
122
123     GOptionArg carg_type_;
124     void* carg_;
125     void* cpparg_;
126     OptionEntry* entry_;
127   };
128
129   void add_entry_with_wrapper(const OptionEntry& entry, GOptionArg arg_type, void* cpp_arg);
130
131   //Map of entry names to CppOptionEntry:
132   typedef std::map<Glib::ustring, CppOptionEntry> type_map_entries;
133   type_map_entries map_entries_;
134
135   GOptionGroup* gobject_;
136   bool has_ownership_; //Whether the gobject_ belongs to this C++ instance.
137 #endif //DOXYGEN_SHOULD_SKIP_THIS
138
139
140 };
141
142 } // namespace Glib
143
144
145 #endif /* _GLIBMM_OPTIONGROUP_H */
146