epoc32/include/stdapis/glib-2.0/glib/goption.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
     1 goption.h
     1 /* goption.h - Option parser
       
     2  *
       
     3  *  Copyright (C) 2004  Anders Carlsson <andersca@gnome.org>
       
     4  * Portions copyright (c) 2006 Nokia Corporation.  All rights reserved.
       
     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
       
    18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
       
    19  * Boston, MA 02111-1307, USA.
       
    20  */
       
    21 
       
    22 #ifndef __G_OPTION_H__
       
    23 #define __G_OPTION_H__
       
    24 
       
    25 #include <_ansi.h>
       
    26 #include <glib/gerror.h>
       
    27 #include <glib/gquark.h>
       
    28 
       
    29 G_BEGIN_DECLS
       
    30 
       
    31 typedef struct _GOptionContext GOptionContext;
       
    32 typedef struct _GOptionGroup   GOptionGroup;
       
    33 typedef struct _GOptionEntry   GOptionEntry;
       
    34 
       
    35 typedef enum
       
    36 {
       
    37   G_OPTION_FLAG_HIDDEN		= 1 << 0,
       
    38   G_OPTION_FLAG_IN_MAIN		= 1 << 1,
       
    39   G_OPTION_FLAG_REVERSE		= 1 << 2,
       
    40   G_OPTION_FLAG_NO_ARG		= 1 << 3,
       
    41   G_OPTION_FLAG_FILENAME	= 1 << 4,
       
    42   G_OPTION_FLAG_OPTIONAL_ARG    = 1 << 5,
       
    43   G_OPTION_FLAG_NOALIAS	        = 1 << 6
       
    44 } GOptionFlags;
       
    45 
       
    46 typedef enum
       
    47 {
       
    48   G_OPTION_ARG_NONE,
       
    49   G_OPTION_ARG_STRING,
       
    50   G_OPTION_ARG_INT,
       
    51   G_OPTION_ARG_CALLBACK,
       
    52   G_OPTION_ARG_FILENAME,
       
    53   G_OPTION_ARG_STRING_ARRAY,
       
    54   G_OPTION_ARG_FILENAME_ARRAY
       
    55 } GOptionArg;
       
    56 
       
    57 typedef gboolean (*GOptionArgFunc) (const gchar    *option_name,
       
    58 				    const gchar    *value,
       
    59 				    gpointer        data,
       
    60 				    GError        **error);
       
    61 
       
    62 typedef gboolean (*GOptionParseFunc) (GOptionContext *context,
       
    63 				      GOptionGroup   *group,
       
    64 				      gpointer	      data,
       
    65 				      GError        **error);
       
    66 
       
    67 typedef void (*GOptionErrorFunc) (GOptionContext *context,
       
    68 				  GOptionGroup   *group,
       
    69 				  gpointer        data,
       
    70 				  GError        **error);
       
    71 
       
    72 #define G_OPTION_ERROR (g_option_error_quark ())
       
    73 
       
    74 typedef enum
       
    75 {
       
    76   G_OPTION_ERROR_UNKNOWN_OPTION,
       
    77   G_OPTION_ERROR_BAD_VALUE,
       
    78   G_OPTION_ERROR_FAILED
       
    79 } GOptionError;
       
    80 
       
    81 IMPORT_C GQuark g_option_error_quark (void);
       
    82 
       
    83 
       
    84 struct _GOptionEntry
       
    85 {
       
    86   const gchar *long_name;
       
    87   gchar        short_name;
       
    88   gint         flags;
       
    89 
       
    90   GOptionArg   arg;
       
    91   gpointer     arg_data;
       
    92   
       
    93   const gchar *description;
       
    94   const gchar *arg_description;
       
    95 };
       
    96 
       
    97 #define G_OPTION_REMAINING ""
       
    98 
       
    99 IMPORT_C GOptionContext *g_option_context_new              (const gchar         *parameter_string);
       
   100 IMPORT_C void            g_option_context_free             (GOptionContext      *context);
       
   101 IMPORT_C void		g_option_context_set_help_enabled (GOptionContext      *context,
       
   102 						   gboolean		help_enabled);
       
   103 IMPORT_C gboolean	g_option_context_get_help_enabled (GOptionContext      *context);
       
   104 IMPORT_C void		g_option_context_set_ignore_unknown_options (GOptionContext *context,
       
   105 							     gboolean	     ignore_unknown);
       
   106 IMPORT_C gboolean        g_option_context_get_ignore_unknown_options (GOptionContext *context);
       
   107 
       
   108 IMPORT_C void            g_option_context_add_main_entries (GOptionContext      *context,
       
   109 						   const GOptionEntry  *entries,
       
   110 						   const gchar         *translation_domain);
       
   111 IMPORT_C gboolean        g_option_context_parse            (GOptionContext      *context,
       
   112 						   gint                *argc,
       
   113 						   gchar             ***argv,
       
   114 						   GError             **error);
       
   115 
       
   116 IMPORT_C void          g_option_context_add_group      (GOptionContext *context,
       
   117 					       GOptionGroup   *group);
       
   118 IMPORT_C void          g_option_context_set_main_group (GOptionContext *context,
       
   119 					       GOptionGroup   *group);
       
   120 IMPORT_C GOptionGroup *g_option_context_get_main_group (GOptionContext *context);
       
   121 
       
   122 
       
   123 IMPORT_C GOptionGroup *g_option_group_new                    (const gchar        *name,
       
   124 						     const gchar        *description,
       
   125 						     const gchar        *help_description,
       
   126 						     gpointer            user_data,
       
   127 						     GDestroyNotify      destroy);
       
   128 IMPORT_C void	      g_option_group_set_parse_hooks	    (GOptionGroup       *group,
       
   129 						     GOptionParseFunc    pre_parse_func,
       
   130 						     GOptionParseFunc	 post_parse_func);
       
   131 IMPORT_C void	      g_option_group_set_error_hook	    (GOptionGroup       *group,
       
   132 						     GOptionErrorFunc	 error_func);
       
   133 IMPORT_C void          g_option_group_free                   (GOptionGroup       *group);
       
   134 IMPORT_C void          g_option_group_add_entries            (GOptionGroup       *group,
       
   135 						     const GOptionEntry *entries);
       
   136 IMPORT_C void          g_option_group_set_translate_func     (GOptionGroup       *group,
       
   137 						     GTranslateFunc      func,
       
   138 						     gpointer            data,
       
   139 						     GDestroyNotify      destroy_notify);
       
   140 IMPORT_C void          g_option_group_set_translation_domain (GOptionGroup       *group,
       
   141 						     const gchar        *domain);
       
   142 
       
   143 
       
   144 G_END_DECLS
       
   145 
       
   146 #endif /* __G_OPTION_H__ */