/src/wrappers/glib/library/utilities/g_option_entry.e
Specman e | 134 lines | 66 code | 21 blank | 47 comment | 2 complexity | 5cde799bf1fe14c1746140636981b3d8 MD5 | raw file
1indexing 2 description: "." 3 copyright: "[ 4 Copyright (C) 2007 $EWLC_developer, $original_copyright_holder 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 22deferred class G_OPTION_ENTRY 23 -- A GOptionEntry defines a single option. To have an effect, they 24 -- must be added to a G_OPTION_GROUP with G_OPTION_CONTEXT's 25 -- `add_main_entries' or G_OPTION_GROUP's `add_entries'. 26 27inherit 28 C_STRUCT redefine fill_tagged_out_memory end 29 MIXED_MEMORY_HANDLING redefine fill_tagged_out_memory end 30 31insert 32 GOPTION_ENTRY_STRUCT undefine fill_tagged_out_memory end 33 -- G_OPTION_ARG_ENUM undefine fill_tagged_out_memory end 34 35feature {} -- Creation 36 make (a_long_name: STRING; a_short_name: CHARACTER; a_description: STRING) is 37 require 38 long_name_not_void: a_long_name /= Void 39 description_not_void: a_description /= Void 40 do 41 allocate 42 goption_entry_struct_set_long_name (handle, a_long_name.to_external) 43 goption_entry_struct_set_short_name (handle,a_short_name) 44 goption_entry_struct_set_description (handle, a_description.to_external) 45 46 -- GOptionArg arg; The type of the option, as a GOptionArg. 47 48 --gpointer arg_data; If the arg type is G_OPTION_ARG_CALLBACK, then 49 --arg_data must point to a GOptionArgFunc callback function, which 50 --will be called to handle the extra argument. Otherwise, arg_data 51 --is a pointer to a location to store the value, the required type 52 --of the location depends on the arg type: 53 54 -- G_OPTION_ARG_NONE gboolean 55 -- G_OPTION_ARG_STRING gchar* 56 -- G_OPTION_ARG_INT gint 57 -- G_OPTION_ARG_FILENAME gchar* 58 -- G_OPTION_ARG_STRING_ARRAY gchar** 59 -- G_OPTION_ARG_FILENAME_ARRAY gchar** 60 -- G_OPTION_ARG_DOUBLE gdouble 61 end 62 63feature -- Queries 64 long_name: FIXED_STRING is 65 -- The long name of an option can be used to specify it in a 66 -- commandline as --long_name. Every option must have a long 67 -- name. To resolve conflicts if multiple option groups 68 -- contain the same long name, it is also possible to specify 69 -- the option as "--groupname-long_name". 70 do 71 create Result.from_external 72 (goption_entry_struct_get_long_name(handle)) 73 end 74 75 short_name: CHARACTER is 76 -- If an option has a short name, it can be specified 77 -- -short_name in a commandline. short_name must be a 78 -- printable ASCII character different from '-', or zero if 79 -- the option has no short name. 80 do 81 Result:=goption_entry_struct_get_short_name(handle) 82 end 83 84 flags: GOPTION_FLAGS_ENUM is 85 -- Flags from GOptionFlags. 86 do 87 Result.change_value(goption_entry_struct_get_flags(handle)) 88 end 89 90 91 argument_type: GOPTION_ARG_ENUM is 92 --The type of the option, as a GOptionArg. 93 do 94 Result.change_value(goption_entry_struct_get_arg(handle)) 95 end 96 97 -- TODO: gpointer arg_data; If the arg type is G_OPTION_ARG_CALLBACK, then 98 --arg_data must point to a GOptionArgFunc callback function, which 99 --will be called to handle the extra argument. Otherwise, arg_data 100 --is a pointer to a location to store the value, the required type 101 --of the location depends on the arg type: 102 103 -- G_OPTION_ARG_NONE gboolean 104 -- G_OPTION_ARG_STRING gchar* 105 -- G_OPTION_ARG_INT gint 106 -- G_OPTION_ARG_FILENAME gchar* 107 -- G_OPTION_ARG_STRING_ARRAY gchar** 108 -- G_OPTION_ARG_FILENAME_ARRAY gchar** 109 -- G_OPTION_ARG_DOUBLE gdouble 110 111 description: FIXED_STRING is 112 -- the description for the option in "--help" output. The description 113 -- is translated using the translate_func of the group, see 114 -- G_OPTION_GROUP.set_translation_domain. 115 do 116 create Result.from_external(goption_entry_struct_get_description(handle)) 117 end 118 119 -- gchar *arg_description; The placeholder to use for the extra 120 -- argument parsed by the option in --help output. The 121 -- arg_description is translated using the translate_func of the 122 -- group, see g_option_group_set_translation_domain(). 123 124 fill_tagged_out_memory is 125 do 126 tagged_out_memory.append(long_name) 127 tagged_out_memory.append(once " '") 128 tagged_out_memory.extend(short_name) 129 tagged_out_memory.append(once "' %"") 130 tagged_out_memory.append(description) 131 tagged_out_memory.append(once "%" ") 132 end 133 134end -- class G_OPTION_ENTRY