/src/wrappers/glib/library/utilities/g_option_group.e
Specman e | 176 lines | 50 code | 43 blank | 83 comment | 2 complexity | 0e65e66be4261cec94cdaa887857fe97 MD5 | raw file
1indexing 2 description: "." 3 copyright: "[ 4 Copyright (C) 2007 Paolo Redaelli, Glib developers 5 6 This library is free software; you can redistribute it and/or 7 modify it under the terms of the GNU Lesser General Public License 8 as published by the Free Software Foundation; either version 2.1 of 9 the License, or (at your option) any later version. 10 11 This library is distributed in the hopeOA that it will be useful, but 12 WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 Lesser General Public License for more details. 15 16 You should have received a copy of the GNU Lesser General Public 17 License along with this library; if not, write to the Free Software 18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19 02110-1301 USA 20 ]" 21 22class G_OPTION_GROUP 23 -- A GOptionGroup struct defines the options in a single group. The 24 -- struct has only private fields and should not be directly 25 -- accessed. 26 27 -- All options in a group share the same translation 28 -- function. Libaries which need to parse commandline options are 29 -- expected to provide a function for getting a GOptionGroup 30 -- holding their options, which the application can then add to its 31 -- GOptionContext. 32 33inherit 34 C_STRUCT redefine free end 35 EIFFEL_OWNED redefine free end 36 37insert 38 SHARED_G_ERROR 39 GOPTION_EXTERNALS 40 GOPTION_GROUP_STRUCT 41 42creation make, from_external_pointer 43 44feature {} -- Creation 45 make (a_name, a_description, an_help_description: STRING) is 46 -- Creates a new GOptionGroup to be added to a GOptionContext. 47 48 -- `a_name': the name for the option group, this is used to provide 49 -- help for the options in this group with --help-name 50 51 -- `a_description': a description for this group to be shown in 52 -- --help. This string is translated using the translation domain or 53 -- translation function of the group 54 55 -- `an_help_description' : a description for the --help-name 56 -- option. This string is translated using the translation domain or 57 -- translation function of the group 58 do 59 from_external_pointer 60 (g_option_group_new 61 (a_name.to_external, a_description.to_external, 62 an_help_description.to_external, 63 default_pointer, 64 -- `user_data' : user data that will be passed to the pre- and 65 -- post-parse hooks, the error hook and to callbacks of 66 -- G_OPTION_ARG_CALLBACK options, or NULL 67 default_pointer -- destroy: a function that will be called to free user_data, or NULL 68 )) 69 end 70 71 free (p: POINTER) is 72 do 73 -- Frees a GOptionGroup. 74 -- Note that you must not free groups which have 75 -- been added to a GOptionContext. 76 -- g_option_group_free(handle) 77 end 78 79 add_entries (some_entries: C_ARRAY[G_OPTION_ENTRY]) is 80 -- Adds the options specified in entries to group. 81 do 82 -- void g_option_group_add_entries (GOptionGroup *group, const 83 -- GOptionEntry *entries); entries is a NULL-terminated array of 84 -- GOptionEntrys 85 g_option_group_add_entries(handle, some_entries.storage.to_external) 86 end 87 88 89 -- GOptionParseFunc () 90 91 -- gboolean (*GOptionParseFunc) (GOptionContext *context, GOptionGroup 92 -- *group, gpointer data, GError **error); 93 94 -- The type of function that can be called before and after parsing. 95 96 -- context : The active GOptionContext 97 -- group : The group to which the function belongs 98 -- data : User data added to the GOptionGroup containing the option when it was 99 -- created with g_option_group_new() 100 -- error : A return location for error details 101 -- Returns : TRUE if the function completed successfully, FALSE if an error 102 -- occurred, in which case error should be set with g_set_error() 103 104 -- g_option_group_set_parse_hooks () 105 106 -- void g_option_group_set_parse_hooks (GOptionGroup *group, 107 -- GOptionParseFunc pre_parse_func, GOptionParseFunc post_parse_func); 108 109 -- Associates two functions with group which will be called from 110 -- g_option_context_parse() before the first option is parsed and after the 111 -- last option has been parsed, respectively. 112 113 -- Note that the user data to be passed to pre_parse_func and post_parse_func can be 114 -- specified when constructing the group with g_option_group_new(). 115 116 -- group : a GOptionGroup 117 -- pre_parse_func : a function to call before parsing, or NULL 118 -- post_parse_func : a function to call after parsing, or NULL 119 120 -- Since 2.6 121 122 -- GOptionErrorFunc () 123 124 -- void (*GOptionErrorFunc) (GOptionContext *context, GOptionGroup *group, 125 -- gpointer data, GError **error); 126 127 -- The type of function to be used as callback when a parse error occurs. 128 129 -- context : The active GOptionContext 130 -- group : The group to which the function belongs 131 -- data : User data added to the GOptionGroup containing the option when it was 132 -- created with g_option_group_new() 133 -- error : The GError containing details about the parse error 134 135 136 -- g_option_group_set_error_hook () 137 138 -- void g_option_group_set_error_hook (GOptionGroup *group, GOptionErrorFunc 139 -- error_func); 140 141 -- Associates a function with group which will be called from 142 -- g_option_context_parse() when an error occurs. 143 144 -- Note that the user data to be passed to pre_parse_func and post_parse_func can be 145 -- specified when constructing the group with g_option_group_new(). 146 147 -- group : a GOptionGroup 148 -- error_func : a function to call when an error occurs 149 150 -- g_option_group_set_translate_func () 151 152 -- void g_option_group_set_translate_func (GOptionGroup *group, 153 -- GTranslateFunc func, gpointer data, GDestroyNotify destroy_notify); 154 155 -- Sets the function which is used to translate user-visible strings, for 156 -- --help output. Different groups can use different GTranslateFuncs. If func 157 -- is NULL, strings are not translated. 158 159 -- If you are using gettext(), you only need to set the translation domain, see 160 -- g_option_group_set_translation_domain(). 161 162 -- group : a GOptionGroup 163 -- func : the GTranslateFunc, or NULL 164 -- data : user data to pass to func, or NULL 165 -- destroy_notify : a function which gets called to free data, or NULL 166 167 set_translation_domain (a_domain: STRING) is 168 -- A convenience feature to use gettext for translating user-visible 169 -- strings; 'a_domain' is the domain to use. 170 require a_domain/=Void 171 do 172 g_option_group_set_translation_domain(handle, a_domain.to_external) 173 end 174 175end -- class G_OPTION_GROUP 176