1 /* goption.h - Option parser
3 * Copyright (C) 2004 Anders Carlsson <andersca@gnome.org>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
21 #ifndef __G_OPTION_H__
22 #define __G_OPTION_H__
24 #include <glib/gerror.h>
25 #include <glib/gquark.h>
29 typedef struct _GOptionContext GOptionContext;
30 typedef struct _GOptionGroup GOptionGroup;
31 typedef struct _GOptionEntry GOptionEntry;
35 G_OPTION_FLAG_HIDDEN = 1 << 0,
36 G_OPTION_FLAG_IN_MAIN = 1 << 1,
37 G_OPTION_FLAG_REVERSE = 1 << 2,
38 G_OPTION_FLAG_NO_ARG = 1 << 3,
39 G_OPTION_FLAG_FILENAME = 1 << 4,
40 G_OPTION_FLAG_OPTIONAL_ARG = 1 << 5,
41 G_OPTION_FLAG_NOALIAS = 1 << 6
49 G_OPTION_ARG_CALLBACK,
50 G_OPTION_ARG_FILENAME,
51 G_OPTION_ARG_STRING_ARRAY,
52 G_OPTION_ARG_FILENAME_ARRAY,
57 typedef gboolean (*GOptionArgFunc) (const gchar *option_name,
62 typedef gboolean (*GOptionParseFunc) (GOptionContext *context,
67 typedef void (*GOptionErrorFunc) (GOptionContext *context,
72 #define G_OPTION_ERROR (g_option_error_quark ())
76 G_OPTION_ERROR_UNKNOWN_OPTION,
77 G_OPTION_ERROR_BAD_VALUE,
81 GQuark g_option_error_quark (void);
86 const gchar *long_name;
93 const gchar *description;
94 const gchar *arg_description;
97 #define G_OPTION_REMAINING ""
99 GOptionContext *g_option_context_new (const gchar *parameter_string);
100 void g_option_context_set_summary (GOptionContext *context,
101 const gchar *summary);
102 G_CONST_RETURN gchar *g_option_context_get_summary (GOptionContext *context);
103 void g_option_context_set_description (GOptionContext *context,
104 const gchar *description);
105 G_CONST_RETURN gchar *g_option_context_get_description (GOptionContext *context);
106 void g_option_context_free (GOptionContext *context);
107 void g_option_context_set_help_enabled (GOptionContext *context,
108 gboolean help_enabled);
109 gboolean g_option_context_get_help_enabled (GOptionContext *context);
110 void g_option_context_set_ignore_unknown_options (GOptionContext *context,
111 gboolean ignore_unknown);
112 gboolean g_option_context_get_ignore_unknown_options (GOptionContext *context);
114 void g_option_context_add_main_entries (GOptionContext *context,
115 const GOptionEntry *entries,
116 const gchar *translation_domain);
117 gboolean g_option_context_parse (GOptionContext *context,
121 void g_option_context_set_translate_func (GOptionContext *context,
124 GDestroyNotify destroy_notify);
125 void g_option_context_set_translation_domain (GOptionContext *context,
126 const gchar *domain);
128 void g_option_context_add_group (GOptionContext *context,
129 GOptionGroup *group);
130 void g_option_context_set_main_group (GOptionContext *context,
131 GOptionGroup *group);
132 GOptionGroup *g_option_context_get_main_group (GOptionContext *context);
135 GOptionGroup *g_option_group_new (const gchar *name,
136 const gchar *description,
137 const gchar *help_description,
139 GDestroyNotify destroy);
140 void g_option_group_set_parse_hooks (GOptionGroup *group,
141 GOptionParseFunc pre_parse_func,
142 GOptionParseFunc post_parse_func);
143 void g_option_group_set_error_hook (GOptionGroup *group,
144 GOptionErrorFunc error_func);
145 void g_option_group_free (GOptionGroup *group);
146 void g_option_group_add_entries (GOptionGroup *group,
147 const GOptionEntry *entries);
148 void g_option_group_set_translate_func (GOptionGroup *group,
151 GDestroyNotify destroy_notify);
152 void g_option_group_set_translation_domain (GOptionGroup *group,
153 const gchar *domain);
158 #endif /* __G_OPTION_H__ */