![]() | ![]() | ![]() | GLib Reference Manual | ![]() |
---|
Commandline option parserCommandline option parser — |
#include <glib.h> enum GOptionError; #define G_OPTION_ERROR enum GOptionFlags; enum GOptionArg; gboolean (*GOptionArgFunc) (const gchar *option_name, const gchar *value, gpointer data, GError **error); struct GOptionContext; GOptionContext* g_option_context_new (const gchar *parameter_string); void g_option_context_free (GOptionContext *context); gboolean g_option_context_parse (GOptionContext *context, gint *argc, gchar ***argv, GError **error); void g_option_context_set_help_enabled (GOptionContext *context, gboolean help_enabled); gboolean g_option_context_get_help_enabled (GOptionContext *context); void g_option_context_set_ignore_unknown_options (GOptionContext *context, gboolean ignore_unknown); gboolean g_option_context_get_ignore_unknown_options (GOptionContext *context); struct GOptionEntry; void g_option_context_add_main_entries (GOptionContext *context, const GOptionEntry *entries, const gchar *translation_domain); struct GOptionGroup; void g_option_context_add_group (GOptionContext *context, GOptionGroup *group); void g_option_context_set_main_group (GOptionContext *context, GOptionGroup *group); GOptionGroup* g_option_context_get_main_group (GOptionContext *context); GOptionGroup* g_option_group_new (const gchar *name, const gchar *description, const gchar *help_description, gpointer user_data, GDestroyNotify destroy); void g_option_group_free (GOptionGroup *group); void g_option_group_add_entries (GOptionGroup *group, const GOptionEntry *entries); gboolean (*GOptionParseFunc) (GOptionContext *context, GOptionGroup *group, gpointer data, GError **error); void g_option_group_set_parse_hooks (GOptionGroup *group, GOptionParseFunc pre_parse_func, GOptionParseFunc post_parse_func); void (*GOptionErrorFunc) (GOptionContext *context, GOptionGroup *group, gpointer data, GError **error); void g_option_group_set_error_hook (GOptionGroup *group, GOptionErrorFunc error_func); const gchar* (*GTranslateFunc) (const gchar *str, gpointer data); void g_option_group_set_translate_func (GOptionGroup *group, GTranslateFunc func, gpointer data, GDestroyNotify destroy_notify); void g_option_group_set_translation_domain (GOptionGroup *group, const gchar *domain);
typedef enum { G_OPTION_ERROR_UNKNOWN_OPTION, G_OPTION_ERROR_BAD_VALUE, G_OPTION_ERROR_FAILED } GOptionError;
typedef enum { G_OPTION_FLAG_HIDDEN = 1 << 0, G_OPTION_FLAG_IN_MAIN = 1 << 1 } GOptionFlags;
typedef enum { G_OPTION_ARG_NONE, G_OPTION_ARG_STRING, G_OPTION_ARG_INT, G_OPTION_ARG_CALLBACK, G_OPTION_ARG_FILENAME, G_OPTION_ARG_STRING_ARRAY, G_OPTION_ARG_FILENAME_ARRAY } GOptionArg;
gboolean (*GOptionArgFunc) (const gchar *option_name, const gchar *value, gpointer data, GError **error);
option_name : | |
value : | |
data : | |
error : | |
Returns : |
GOptionContext* g_option_context_new (const gchar *parameter_string);
parameter_string : | |
Returns : |
gboolean g_option_context_parse (GOptionContext *context, gint *argc, gchar ***argv, GError **error);
context : | |
argc : | |
argv : | |
error : | |
Returns : |
void g_option_context_set_help_enabled (GOptionContext *context, gboolean help_enabled);
context : | |
help_enabled : |
gboolean g_option_context_get_help_enabled (GOptionContext *context);
context : | |
Returns : |
void g_option_context_set_ignore_unknown_options (GOptionContext *context, gboolean ignore_unknown);
context : | |
ignore_unknown : |
gboolean g_option_context_get_ignore_unknown_options (GOptionContext *context);
context : | |
Returns : |
struct GOptionEntry { const gchar *long_name; gchar short_name; gint flags; GOptionArg arg; gpointer arg_data; const gchar *description; const gchar *arg_description; };
void g_option_context_add_main_entries (GOptionContext *context, const GOptionEntry *entries, const gchar *translation_domain);
context : | |
entries : | |
translation_domain : |
void g_option_context_add_group (GOptionContext *context, GOptionGroup *group);
context : | |
group : |
void g_option_context_set_main_group (GOptionContext *context, GOptionGroup *group);
context : | |
group : |
GOptionGroup* g_option_context_get_main_group (GOptionContext *context);
context : | |
Returns : |
GOptionGroup* g_option_group_new (const gchar *name, const gchar *description, const gchar *help_description, gpointer user_data, GDestroyNotify destroy);
name : | |
description : | |
help_description : | |
user_data : | |
destroy : | |
Returns : |
void g_option_group_add_entries (GOptionGroup *group, const GOptionEntry *entries);
group : | |
entries : |
gboolean (*GOptionParseFunc) (GOptionContext *context, GOptionGroup *group, gpointer data, GError **error);
context : | |
group : | |
data : | |
error : | |
Returns : |
void g_option_group_set_parse_hooks (GOptionGroup *group, GOptionParseFunc pre_parse_func, GOptionParseFunc post_parse_func);
group : | |
pre_parse_func : | |
post_parse_func : |
void (*GOptionErrorFunc) (GOptionContext *context, GOptionGroup *group, gpointer data, GError **error);
context : | |
group : | |
data : | |
error : |
void g_option_group_set_error_hook (GOptionGroup *group, GOptionErrorFunc error_func);
group : | |
error_func : |
const gchar* (*GTranslateFunc) (const gchar *str, gpointer data);
str : | |
data : | |
Returns : |
void g_option_group_set_translate_func (GOptionGroup *group, GTranslateFunc func, gpointer data, GDestroyNotify destroy_notify);
group : | |
func : | |
data : | |
destroy_notify : |
void g_option_group_set_translation_domain (GOptionGroup *group, const gchar *domain);
group : | |
domain : |
<< Shell-related Utilities | Glob-style pattern matching >> |