1 /*
2  * Distributed under the Boost Software License, Version 1.0.
3  *    (See accompanying file LICENSE_1_0.txt or copy at
4  *          http://www.boost.org/LICENSE_1_0.txt)
5  */
6 module glib.goption;
7 
8 import glib.gtypes;
9 import glib.gerror;
10 import glib.gquark;
11 
12 
13 
14 struct GOptionContext;
15 
16 struct GOptionGroup;
17 
18 enum GoptionFlags
19 {
20   G_OPTION_FLAG_NONE            = 0,
21   G_OPTION_FLAG_HIDDEN		= 1 << 0,
22   G_OPTION_FLAG_IN_MAIN		= 1 << 1,
23   G_OPTION_FLAG_REVERSE		= 1 << 2,
24   G_OPTION_FLAG_NO_ARG		= 1 << 3,
25   G_OPTION_FLAG_FILENAME	= 1 << 4,
26   G_OPTION_FLAG_OPTIONAL_ARG    = 1 << 5,
27   G_OPTION_FLAG_NOALIAS	        = 1 << 6
28 }
29 
30 enum GOptionArg
31 {
32   G_OPTION_ARG_NONE,
33   G_OPTION_ARG_STRING,
34   G_OPTION_ARG_INT,
35   G_OPTION_ARG_CALLBACK,
36   G_OPTION_ARG_FILENAME,
37   G_OPTION_ARG_STRING_ARRAY,
38   G_OPTION_ARG_FILENAME_ARRAY,
39   G_OPTION_ARG_DOUBLE,
40   G_OPTION_ARG_INT64
41 }
42 
43 
44 extern (C) {
45 
46     alias GOptionArgFunc = gboolean function (const(gchar)    *option_name,
47                         const(gchar)    *value,
48                         gpointer        data,
49                         GError        **error);
50 
51     alias GOptionParseFunc = gboolean function (GOptionContext *context,
52                           GOptionGroup   *group,
53                           gpointer	      data,
54                           GError        **error);
55 
56     alias GOptionErrorFunc = void function (GOptionContext *context,
57                       GOptionGroup   *group,
58                       gpointer        data,
59                       GError        **error);
60 
61 }
62 
63 
64 //enum G_OPTION_ERROR = g_option_error_quark ();
65 
66 enum GOptionError
67 {
68   G_OPTION_ERROR_UNKNOWN_OPTION,
69   G_OPTION_ERROR_BAD_VALUE,
70   G_OPTION_ERROR_FAILED
71 }
72 
73 
74 extern(C)
75 GQuark g_option_error_quark ();
76 
77 
78 struct GOptionEntry
79 {
80   const(gchar) *long_name;
81   gchar        short_name;
82   gint         flags;
83 
84   GOptionArg   arg;
85   gpointer     arg_data;
86 
87   const(gchar) *description;
88   const(gchar) *arg_description;
89 };
90 
91 
92 extern (C) {
93 
94     GOptionContext *g_option_context_new              (const(gchar)         *parameter_string);
95 
96     void            g_option_context_set_summary      (GOptionContext      *context,
97                                                        const(gchar)         *summary);
98 
99     const(gchar) *   g_option_context_get_summary      (GOptionContext     *context);
100 
101     void            g_option_context_set_description  (GOptionContext      *context,
102                                                        const(gchar)         *description);
103 
104     const(gchar) *   g_option_context_get_description  (GOptionContext     *context);
105 
106     void            g_option_context_free             (GOptionContext      *context);
107 
108     void		g_option_context_set_help_enabled (GOptionContext      *context,
109                                gboolean		help_enabled);
110 
111     gboolean	g_option_context_get_help_enabled (GOptionContext      *context);
112 
113     void		g_option_context_set_ignore_unknown_options (GOptionContext *context,
114                                      gboolean	     ignore_unknown);
115 
116     gboolean        g_option_context_get_ignore_unknown_options (GOptionContext *context);
117 
118 
119     void            g_option_context_add_main_entries (GOptionContext      *context,
120                                const(GOptionEntry)  *entries,
121                                const(gchar)         *translation_domain);
122 
123     gboolean        g_option_context_parse            (GOptionContext      *context,
124                                gint                *argc,
125                                gchar             ***argv,
126                                GError             **error);
127 
128     gboolean        g_option_context_parse_strv       (GOptionContext      *context,
129                                                        gchar             ***arguments,
130                                                        GError             **error);
131 
132     void            g_option_context_set_translate_func (GOptionContext     *context,
133                                  GTranslateFunc      func,
134                                  gpointer            data,
135                                  GDestroyNotify      destroy_notify);
136 
137     void            g_option_context_set_translation_domain (GOptionContext  *context,
138                                  const(gchar)     *domain);
139 
140 
141     void            g_option_context_add_group      (GOptionContext *context,
142                              GOptionGroup   *group);
143 
144     void          g_option_context_set_main_group (GOptionContext *context,
145                                GOptionGroup   *group);
146 
147     GOptionGroup *g_option_context_get_main_group (GOptionContext *context);
148 
149     gchar        *g_option_context_get_help       (GOptionContext *context,
150                                                    gboolean        main_help,
151                                                    GOptionGroup   *group);
152 
153 
154     GOptionGroup *g_option_group_new                    (const(gchar)        *name,
155                                  const(gchar)        *description,
156                                  const(gchar)        *help_description,
157                                  gpointer            user_data,
158                                  GDestroyNotify      destroy);
159 
160     void	      g_option_group_set_parse_hooks	    (GOptionGroup       *group,
161                                  GOptionParseFunc    pre_parse_func,
162                                  GOptionParseFunc	 post_parse_func);
163 
164     void	      g_option_group_set_error_hook	    (GOptionGroup       *group,
165                                  GOptionErrorFunc	 error_func);
166 
167     void          g_option_group_free                   (GOptionGroup       *group);
168 
169     void          g_option_group_add_entries            (GOptionGroup       *group,
170                                  const(GOptionEntry) *entries);
171 
172     void          g_option_group_set_translate_func     (GOptionGroup       *group,
173                                  GTranslateFunc      func,
174                                  gpointer            data,
175                                  GDestroyNotify      destroy_notify);
176 
177     void          g_option_group_set_translation_domain (GOptionGroup       *group,
178                                  const(gchar)        *domain);
179 
180 }
181