?? glib-commandline-option-parser.html
字號:
<a class="indexterm" name="id3129435"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar">gchar</a>* g_option_context_get_help (<a class="link" href="glib-Commandline-option-parser.html#GOptionContext">GOptionContext</a> *context, <a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a> main_help, <a class="link" href="glib-Commandline-option-parser.html#GOptionGroup">GOptionGroup</a> *group);</pre><p>Returns a formatted, translated help text for the given context.To obtain the text produced by <code class="option">--help</code>, call<code class="literal">g_option_context_get_help (context, TRUE, NULL)</code>.To obtain the text produced by <code class="option">--help-all</code>, call<code class="literal">g_option_context_get_help (context, FALSE, NULL)</code>.To obtain the help text for an option group, call<code class="literal">g_option_context_get_help (context, FALSE, group)</code>.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td><td> a <a class="link" href="glib-Commandline-option-parser.html#GOptionContext"><span class="type">GOptionContext</span></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>main_help</code></em> :</span></p></td><td> if <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>, only include the main group </td></tr><tr><td><p><span class="term"><em class="parameter"><code>group</code></em> :</span></p></td><td> the <a class="link" href="glib-Commandline-option-parser.html#GOptionGroup"><span class="type">GOptionGroup</span></a> to create help for, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a></td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> A newly allocated string containing the help text</td></tr></tbody></table></div><p class="since">Since 2.14</p></div><hr><div class="refsect2" lang="en"><a name="id3129614"></a><h3><a name="GOptionArg"></a>enum GOptionArg</h3><a class="indexterm" name="id3129626"></a><pre class="programlisting">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, G_OPTION_ARG_DOUBLE, G_OPTION_ARG_INT64} GOptionArg;</pre><p>The <a class="link" href="glib-Commandline-option-parser.html#GOptionArg"><span class="type">GOptionArg</span></a> enum values determine which type of extra argument theoptions expect to find. If an option expects an extra argument, itcan be specified in several ways; with a short option:<code class="option">-x arg</code>, with a long option: <code class="option">--name arg</code>or combined in a single argument: <code class="option">--name=arg</code>.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><a name="G-OPTION-ARG-NONE:CAPS"></a><code class="literal">G_OPTION_ARG_NONE</code></span></p></td><td>No extra argument. This is useful for simple flags.</td></tr><tr><td><p><span class="term"><a name="G-OPTION-ARG-STRING:CAPS"></a><code class="literal">G_OPTION_ARG_STRING</code></span></p></td><td>The option takes a string argument.</td></tr><tr><td><p><span class="term"><a name="G-OPTION-ARG-INT:CAPS"></a><code class="literal">G_OPTION_ARG_INT</code></span></p></td><td>The option takes an integer argument.</td></tr><tr><td><p><span class="term"><a name="G-OPTION-ARG-CALLBACK:CAPS"></a><code class="literal">G_OPTION_ARG_CALLBACK</code></span></p></td><td>The option provides a callback to parse the extra argument.</td></tr><tr><td><p><span class="term"><a name="G-OPTION-ARG-FILENAME:CAPS"></a><code class="literal">G_OPTION_ARG_FILENAME</code></span></p></td><td>The option takes a filename as argument.</td></tr><tr><td><p><span class="term"><a name="G-OPTION-ARG-STRING-ARRAY:CAPS"></a><code class="literal">G_OPTION_ARG_STRING_ARRAY</code></span></p></td><td>The option takes a string argument, multiple uses of the option are collected into an array of strings.</td></tr><tr><td><p><span class="term"><a name="G-OPTION-ARG-FILENAME-ARRAY:CAPS"></a><code class="literal">G_OPTION_ARG_FILENAME_ARRAY</code></span></p></td><td>The option takes a filename as argument, multiple uses of the option are collected into an array of strings.</td></tr><tr><td><p><span class="term"><a name="G-OPTION-ARG-DOUBLE:CAPS"></a><code class="literal">G_OPTION_ARG_DOUBLE</code></span></p></td><td>The option takes a double argument. The argument can be formatted either for the user's locale or for the "C" locale. Since 2.12</td></tr><tr><td><p><span class="term"><a name="G-OPTION-ARG-INT64:CAPS"></a><code class="literal">G_OPTION_ARG_INT64</code></span></p></td><td>The option takes a 64-bit integer. Like <a class="link" href="glib-Commandline-option-parser.html#G-OPTION-ARG-INT:CAPS"><code class="literal">G_OPTION_ARG_INT</code></a> but for larger numbers. The number can be in decimal base, or in hexadecimal (when prefixed with <code class="literal">0x</code>, for example, <code class="literal">0xffffffff</code>). Since 2.12</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3129908"></a><h3><a name="GOptionFlags"></a>enum GOptionFlags</h3><a class="indexterm" name="id3129920"></a><pre class="programlisting">typedef enum{ G_OPTION_FLAG_HIDDEN = 1 << 0, G_OPTION_FLAG_IN_MAIN = 1 << 1, G_OPTION_FLAG_REVERSE = 1 << 2, G_OPTION_FLAG_NO_ARG = 1 << 3, G_OPTION_FLAG_FILENAME = 1 << 4, G_OPTION_FLAG_OPTIONAL_ARG = 1 << 5, G_OPTION_FLAG_NOALIAS = 1 << 6} GOptionFlags;</pre><p>Flags which modify individual options.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><a name="G-OPTION-FLAG-HIDDEN:CAPS"></a><code class="literal">G_OPTION_FLAG_HIDDEN</code></span></p></td><td>The option doesn't appear in <code class="option">--help</code> output.</td></tr><tr><td><p><span class="term"><a name="G-OPTION-FLAG-IN-MAIN:CAPS"></a><code class="literal">G_OPTION_FLAG_IN_MAIN</code></span></p></td><td>The option appears in the main section of the <code class="option">--help</code> output, even if it is defined in a group.</td></tr><tr><td><p><span class="term"><a name="G-OPTION-FLAG-REVERSE:CAPS"></a><code class="literal">G_OPTION_FLAG_REVERSE</code></span></p></td><td>For options of the <a class="link" href="glib-Commandline-option-parser.html#G-OPTION-ARG-NONE:CAPS"><code class="literal">G_OPTION_ARG_NONE</code></a> kind, this flag indicates that the sense of the option is reversed.</td></tr><tr><td><p><span class="term"><a name="G-OPTION-FLAG-NO-ARG:CAPS"></a><code class="literal">G_OPTION_FLAG_NO_ARG</code></span></p></td><td>For options of the <a class="link" href="glib-Commandline-option-parser.html#G-OPTION-ARG-CALLBACK:CAPS"><code class="literal">G_OPTION_ARG_CALLBACK</code></a> kind, this flag indicates that the callback does not take any argument (like a <a class="link" href="glib-Commandline-option-parser.html#G-OPTION-ARG-NONE:CAPS"><code class="literal">G_OPTION_ARG_NONE</code></a> option). Since 2.8</td></tr><tr><td><p><span class="term"><a name="G-OPTION-FLAG-FILENAME:CAPS"></a><code class="literal">G_OPTION_FLAG_FILENAME</code></span></p></td><td>For options of the <a class="link" href="glib-Commandline-option-parser.html#G-OPTION-ARG-CALLBACK:CAPS"><code class="literal">G_OPTION_ARG_CALLBACK</code></a> kind, this flag indicates that the argument should be passed to the callback in the GLib filename encoding rather than UTF-8. Since 2.8</td></tr><tr><td><p><span class="term"><a name="G-OPTION-FLAG-OPTIONAL-ARG:CAPS"></a><code class="literal">G_OPTION_FLAG_OPTIONAL_ARG</code></span></p></td><td>For options of the <a class="link" href="glib-Commandline-option-parser.html#G-OPTION-ARG-CALLBACK:CAPS"><code class="literal">G_OPTION_ARG_CALLBACK</code></a> kind, this flag indicates that the argument supply is optional. If no argument is given then data of <a class="link" href="glib-Commandline-option-parser.html#GOptionParseFunc"><code class="literal">GOptionParseFunc</code></a> will be set to NULL. Since 2.8</td></tr><tr><td><p><span class="term"><a name="G-OPTION-FLAG-NOALIAS:CAPS"></a><code class="literal">G_OPTION_FLAG_NOALIAS</code></span></p></td><td>This flag turns off the automatic conflict resolution which prefixes long option names with <code class="literal">groupname-</code> if there is a conflict. This option should only be used in situations where aliasing is necessary to model some legacy commandline interface. It is not safe to use this option, unless all option groups are under your direct control. Since 2.8.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3130200"></a><h3><a name="G-OPTION-REMAINING:CAPS"></a>G_OPTION_REMAINING</h3><a class="indexterm" name="id3130216"></a><pre class="programlisting">#define G_OPTION_REMAINING ""</pre><p>If a long option in the main group has this name, it is not treated as a regular option. Instead it collects all non-option arguments which wouldotherwise be left in <code class="literal">argv</code>. The option must be of type<a class="link" href="glib-Commandline-option-parser.html#G-OPTION-ARG-CALLBACK:CAPS"><code class="literal">G_OPTION_ARG_CALLBACK</code></a>, <a class="link" href="glib-Commandline-option-parser.html#G-OPTION-ARG-STRING-ARRAY:CAPS"><code class="literal">G_OPTION_ARG_STRING_ARRAY</code></a>or <a class="link" href="glib-Commandline-option-parser.html#G-OPTION-ARG-FILENAME-ARRAY:CAPS"><code class="literal">G_OPTION_ARG_FILENAME_ARRAY</code></a>.</p><p>Using <a class="link" href="glib-Commandline-option-parser.html#G-OPTION-REMAINING:CAPS"><span class="type">G_OPTION_REMAINING</span></a> instead of simply scanning <code class="literal">argv</code>for leftover arguments has the advantage that GOption takes care of necessary encoding conversions for strings or filenames.</p><p class="since">Since 2.6</p></div><hr><div class="refsect2" lang="
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -