📄 glib-commandline-option-parser.html
字号:
<tr><td><span class="term"><code class="literal">G_OPTION_ARG_FILENAME</code></span></td><td><p><code class="literal">gchar</code>*</p></td></tr><tr><td><span class="term"><code class="literal">G_OPTION_ARG_STRING_ARRAY</code></span></td><td><p><code class="literal">gchar</code>**</p></td></tr><tr><td><span class="term"><code class="literal">G_OPTION_ARG_FILENAME_ARRAY</code></span></td><td><p><code class="literal">gchar</code>**</p></td></tr></tbody></table></div></td></tr><tr><td><span class="term">const <a href="glib-Basic-Types.html#gchar">gchar</a> *<em class="structfield"><code>description</code></em>;</span></td><td>the description for the option in <code class="option">--help</code> output. The <em class="parameter"><code>description</code></em> is translated using the <em class="parameter"><code>translate_func</code></em> of the group, see <a href="glib-Commandline-option-parser.html#g-option-group-set-translation-domain"><code class="function">g_option_group_set_translation_domain()</code></a>.</td></tr><tr><td><span class="term">const <a href="glib-Basic-Types.html#gchar">gchar</a> *<em class="structfield"><code>arg_description</code></em>;</span></td><td>The placeholder to use for the extra argument parsed by the option in <code class="option">--help</code> output. The <em class="parameter"><code>arg_description</code></em> is translated using the <em class="parameter"><code>translate_func</code></em> of the group, see <a href="glib-Commandline-option-parser.html#g-option-group-set-translation-domain"><code class="function">g_option_group_set_translation_domain()</code></a>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3065538"></a><h3><a name="g-option-context-add-main-entries"></a>g_option_context_add_main_entries ()</h3><a class="indexterm" name="id3065550"></a><pre class="programlisting">void g_option_context_add_main_entries (<a href="glib-Commandline-option-parser.html#GOptionContext">GOptionContext</a> *context, const <a href="glib-Commandline-option-parser.html#GOptionEntry">GOptionEntry</a> *entries, const <a href="glib-Basic-Types.html#gchar">gchar</a> *translation_domain);</pre><p>A convenience function which creates a main group if it doesn't exist, adds the <em class="parameter"><code>entries</code></em> to it and sets the translation domain.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>context</code></em> :</span></td><td> a <a href="glib-Commandline-option-parser.html#GOptionContext"><span class="type">GOptionContext</span></a></td></tr><tr><td><span class="term"><em class="parameter"><code>entries</code></em> :</span></td><td> a <code class="literal">NULL</code>-terminated array of <a href="glib-Commandline-option-parser.html#GOptionEntry"><span class="type">GOptionEntry</span></a>s</td></tr><tr><td><span class="term"><em class="parameter"><code>translation_domain</code></em> :</span></td><td> a translation domain to use for translating the <code class="option">--help</code> output for the options in <em class="parameter"><code>entries</code></em> with <ahref="../libbonobo/libbonobo-bonobo-i18n.html#gettext"><code class="function">gettext()</code></a>, or <code class="literal">NULL</code></td></tr></tbody></table></div><p>Since 2.6</p></div><hr><div class="refsect2" lang="en"><a name="id3065707"></a><h3><a name="GOptionGroup"></a>GOptionGroup</h3><a class="indexterm" name="id3065718"></a><pre class="programlisting">typedef struct _GOptionGroup GOptionGroup;</pre><p>A <span class="structname">GOptionGroup</span> struct defines the options in a singlegroup. The struct has only private fields and should not be directly accessed. </p><p>All options in a group share the same translation function. Libaries whichneed to parse commandline options are expected to provide a function forgetting a <span class="structname">GOptionGroup</span> holding their options, which the application can then add to its <a href="glib-Commandline-option-parser.html#GOptionContext"><span class="type">GOptionContext</span></a>.</p></div><hr><div class="refsect2" lang="en"><a name="id3065758"></a><h3><a name="g-option-context-add-group"></a>g_option_context_add_group ()</h3><a class="indexterm" name="id3065770"></a><pre class="programlisting">void g_option_context_add_group (<a href="glib-Commandline-option-parser.html#GOptionContext">GOptionContext</a> *context, <a href="glib-Commandline-option-parser.html#GOptionGroup">GOptionGroup</a> *group);</pre><p>Adds a <a href="glib-Commandline-option-parser.html#GOptionGroup"><span class="type">GOptionGroup</span></a> to the <em class="parameter"><code>context</code></em>, so that parsing with <em class="parameter"><code>context</code></em>will recognize the options in the group. Note that the group willbe freed together with the context when <a href="glib-Commandline-option-parser.html#g-option-context-free"><code class="function">g_option_context_free()</code></a> iscalled, so you must not free the group yourself after adding itto a context.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>context</code></em> :</span></td><td> a <a href="glib-Commandline-option-parser.html#GOptionContext"><span class="type">GOptionContext</span></a></td></tr><tr><td><span class="term"><em class="parameter"><code>group</code></em> :</span></td><td> the group to add</td></tr></tbody></table></div><p>Since 2.6</p></div><hr><div class="refsect2" lang="en"><a name="id3065888"></a><h3><a name="g-option-context-set-main-group"></a>g_option_context_set_main_group ()</h3><a class="indexterm" name="id3065900"></a><pre class="programlisting">void g_option_context_set_main_group (<a href="glib-Commandline-option-parser.html#GOptionContext">GOptionContext</a> *context, <a href="glib-Commandline-option-parser.html#GOptionGroup">GOptionGroup</a> *group);</pre><p>Sets a <a href="glib-Commandline-option-parser.html#GOptionGroup"><span class="type">GOptionGroup</span></a> as main group of the <em class="parameter"><code>context</code></em>. This has the same effect as calling <a href="glib-Commandline-option-parser.html#g-option-context-add-group"><code class="function">g_option_context_add_group()</code></a>, the only difference is that the options in the main group are treated differently when generating <code class="option">--help</code> output.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>context</code></em> :</span></td><td> a <a href="glib-Commandline-option-parser.html#GOptionContext"><span class="type">GOptionContext</span></a></td></tr><tr><td><span class="term"><em class="parameter"><code>group</code></em> :</span></td><td> the group to set as main group</td></tr></tbody></table></div><p>Since 2.6</p></div><hr><div class="refsect2" lang="en"><a name="id3066017"></a><h3><a name="g-option-context-get-main-group"></a>g_option_context_get_main_group ()</h3><a class="indexterm" name="id3066028"></a><pre class="programlisting"><a href="glib-Commandline-option-parser.html#GOptionGroup">GOptionGroup</a>* g_option_context_get_main_group (<a href="glib-Commandline-option-parser.html#GOptionContext">GOptionContext</a> *context);</pre><p>Returns a pointer to the main group of <em class="parameter"><code>context</code></em>.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>context</code></em> :</span></td><td> a <a href="glib-Commandline-option-parser.html#GOptionContext"><span class="type">GOptionContext</span></a></td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> the main group of <em class="parameter"><code>context</code></em>, or <code class="literal">NULL</code> if <em class="parameter"><code>context</code></em> doesn't have a main group. Note that group belongs to <em class="parameter"><code>context</code></em> and should not be modified or freed.</td></tr></tbody></table></div><p>Since 2.6</p></div><hr><div class="refsect2" lang="en"><a name="id3066134"></a><h3><a name="g-option-group-new"></a>g_option_group_new ()</h3><a class="indexterm" name="id3066145"></a><pre class="programlisting"><a href="glib-Commandline-option-parser.html#GOptionGroup">GOptionGroup</a>* g_option_group_new (const <a href="glib-Basic-Types.html#gchar">gchar</a> *name, const <a href="glib-Basic-Types.html#gchar">gchar</a> *description, const <a href="glib-Basic-Types.html#gchar">gchar</a> *help_description, <a href="glib-Basic-Types.html#gpointer">gpointer</a> user_data, <a href="glib-Datasets.html#GDestroyNotify">GDestroyNotify</a> destroy);</pre><p>Creates a new <a href="glib-Commandline-option-parser.html#GOptionGroup"><span class="type">GOptionGroup</span></a>.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>name</code></em> :</span></td><td> the name for the option group, this is used to provide help for the options in this group with <code class="option">--help-</code><em class="parameter"><code>name</code></em></td></tr><tr><td><span class="term"><em class="parameter"><code>description</code></em> :</span></td><td> a description for this group to be shown in <code class="option">--help</code>. This string is translated using the translation domain or translation function of the group</td></tr><tr><td><span class="term"><em class="parameter"><code>help_description</code></em> :</span></td><td> a description for the <code class="option">--help-</code><em class="parameter"><code>name</code></em> option. This string is translated using the translation domain or translation function of the group</td></tr><tr><td><span class="term"><em class="parameter"><code>user_data</code></em> :</span></td><td> user data that will be passed to the pre- and post-parse hooks, the error hook and to callbacks of <code class="literal">G_OPTION_ARG_CALLBACK</code> options, or <code class="literal">NULL</code></td></tr><tr><td><span class="term"><em class="parameter"><code>destroy</code></em> :</span></td><td> a function that will be called to free <em class="parameter"><code>user_data</code></em>, or <code class="literal">NULL</code></td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> a newly created option group. It should be added to a <a href="glib-Commandline-option-parser.html#GOptionContext"><span class="type">GOptionContext</span></a> or freed with <a href="glib-Commandline-option-parser.html#g-option-group-free"><code class="function">g_option_group_free()</code></a>.</td></tr></tbody></table></div><p>Since 2.6</p></div><hr><div class="refsect2" lang="en"><a name="id3066376"></a><h3><a name="g-option-group-free"></a>g_option_group_free ()</h3><a class="indexterm" name="id3066387"></a><pre class="programlisting">void g_option_group_free (<a href="glib-Commandline-option-parser.html#GOptionGroup">GOptionGroup</a> *group);</pre><p>Frees a <a href="glib-Commandline-option-parser.html#GOptionGroup"><span class="type">GOptionGroup</span></a>. Note that you must <span class="emphasis"><em>not</em></span>free groups which have been added to a <a href="glib-Commandline-option-parser.html#GOptionContext"><span class="type">GOptionContext</span></a>.</p><p></p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -