/src/wrappers/glib/library/utilities/g_option_entry.e

http://github.com/tybor/Liberty · Specman e · 134 lines · 66 code · 21 blank · 47 comment · 2 complexity · 5cde799bf1fe14c1746140636981b3d8 MD5 · raw file

  1. indexing
  2. description: "."
  3. copyright: "[
  4. Copyright (C) 2007 $EWLC_developer, $original_copyright_holder
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public License
  7. as published by the Free Software Foundation; either version 2.1 of
  8. the License, or (at your option) any later version.
  9. This library is distributed in the hopeOA that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. 02110-1301 USA
  17. ]"
  18. deferred class G_OPTION_ENTRY
  19. -- A GOptionEntry defines a single option. To have an effect, they
  20. -- must be added to a G_OPTION_GROUP with G_OPTION_CONTEXT's
  21. -- `add_main_entries' or G_OPTION_GROUP's `add_entries'.
  22. inherit
  23. C_STRUCT redefine fill_tagged_out_memory end
  24. MIXED_MEMORY_HANDLING redefine fill_tagged_out_memory end
  25. insert
  26. GOPTION_ENTRY_STRUCT undefine fill_tagged_out_memory end
  27. -- G_OPTION_ARG_ENUM undefine fill_tagged_out_memory end
  28. feature {} -- Creation
  29. make (a_long_name: STRING; a_short_name: CHARACTER; a_description: STRING) is
  30. require
  31. long_name_not_void: a_long_name /= Void
  32. description_not_void: a_description /= Void
  33. do
  34. allocate
  35. goption_entry_struct_set_long_name (handle, a_long_name.to_external)
  36. goption_entry_struct_set_short_name (handle,a_short_name)
  37. goption_entry_struct_set_description (handle, a_description.to_external)
  38. -- GOptionArg arg; The type of the option, as a GOptionArg.
  39. --gpointer arg_data; If the arg type is G_OPTION_ARG_CALLBACK, then
  40. --arg_data must point to a GOptionArgFunc callback function, which
  41. --will be called to handle the extra argument. Otherwise, arg_data
  42. --is a pointer to a location to store the value, the required type
  43. --of the location depends on the arg type:
  44. -- G_OPTION_ARG_NONE gboolean
  45. -- G_OPTION_ARG_STRING gchar*
  46. -- G_OPTION_ARG_INT gint
  47. -- G_OPTION_ARG_FILENAME gchar*
  48. -- G_OPTION_ARG_STRING_ARRAY gchar**
  49. -- G_OPTION_ARG_FILENAME_ARRAY gchar**
  50. -- G_OPTION_ARG_DOUBLE gdouble
  51. end
  52. feature -- Queries
  53. long_name: FIXED_STRING is
  54. -- The long name of an option can be used to specify it in a
  55. -- commandline as --long_name. Every option must have a long
  56. -- name. To resolve conflicts if multiple option groups
  57. -- contain the same long name, it is also possible to specify
  58. -- the option as "--groupname-long_name".
  59. do
  60. create Result.from_external
  61. (goption_entry_struct_get_long_name(handle))
  62. end
  63. short_name: CHARACTER is
  64. -- If an option has a short name, it can be specified
  65. -- -short_name in a commandline. short_name must be a
  66. -- printable ASCII character different from '-', or zero if
  67. -- the option has no short name.
  68. do
  69. Result:=goption_entry_struct_get_short_name(handle)
  70. end
  71. flags: GOPTION_FLAGS_ENUM is
  72. -- Flags from GOptionFlags.
  73. do
  74. Result.change_value(goption_entry_struct_get_flags(handle))
  75. end
  76. argument_type: GOPTION_ARG_ENUM is
  77. --The type of the option, as a GOptionArg.
  78. do
  79. Result.change_value(goption_entry_struct_get_arg(handle))
  80. end
  81. -- TODO: gpointer arg_data; If the arg type is G_OPTION_ARG_CALLBACK, then
  82. --arg_data must point to a GOptionArgFunc callback function, which
  83. --will be called to handle the extra argument. Otherwise, arg_data
  84. --is a pointer to a location to store the value, the required type
  85. --of the location depends on the arg type:
  86. -- G_OPTION_ARG_NONE gboolean
  87. -- G_OPTION_ARG_STRING gchar*
  88. -- G_OPTION_ARG_INT gint
  89. -- G_OPTION_ARG_FILENAME gchar*
  90. -- G_OPTION_ARG_STRING_ARRAY gchar**
  91. -- G_OPTION_ARG_FILENAME_ARRAY gchar**
  92. -- G_OPTION_ARG_DOUBLE gdouble
  93. description: FIXED_STRING is
  94. -- the description for the option in "--help" output. The description
  95. -- is translated using the translate_func of the group, see
  96. -- G_OPTION_GROUP.set_translation_domain.
  97. do
  98. create Result.from_external(goption_entry_struct_get_description(handle))
  99. end
  100. -- gchar *arg_description; The placeholder to use for the extra
  101. -- argument parsed by the option in --help output. The
  102. -- arg_description is translated using the translate_func of the
  103. -- group, see g_option_group_set_translation_domain().
  104. fill_tagged_out_memory is
  105. do
  106. tagged_out_memory.append(long_name)
  107. tagged_out_memory.append(once " '")
  108. tagged_out_memory.extend(short_name)
  109. tagged_out_memory.append(once "' %"")
  110. tagged_out_memory.append(description)
  111. tagged_out_memory.append(once "%" ")
  112. end
  113. end -- class G_OPTION_ENTRY