📄 glib-key-value-file-parser.html
字号:
<span class="term"><em class="parameter"><code>error</code></em> :</span></td><td> return location for a <a href="glib-Error-Reporting.html#GError"><span class="type">GError</span></a>, or <code class="literal">NULL</code></td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> <code class="literal">TRUE</code> if a key file could be loaded, <code class="literal">FALSE</code> othewise</td></tr></tbody></table></div><p>Since 2.6</p></div><hr><div class="refsect2" lang="en"><a name="id3083432"></a><h3><a name="g-key-file-load-from-data"></a>g_key_file_load_from_data ()</h3><a class="indexterm" name="id3083441"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gboolean">gboolean</a> g_key_file_load_from_data (<a href="glib-Key-value-file-parser.html#GKeyFile">GKeyFile</a> *key_file, const <a href="glib-Basic-Types.html#gchar">gchar</a> *data, <a href="glib-Basic-Types.html#gsize">gsize</a> length, <a href="glib-Key-value-file-parser.html#GKeyFileFlags">GKeyFileFlags</a> flags, <a href="glib-Error-Reporting.html#GError">GError</a> **error);</pre><p>Loads a key file from memory into an empty <a href="glib-Key-value-file-parser.html#GKeyFile"><span class="type">GKeyFile</span></a> structure. Ifthe object cannot be created then <code class="literal">error</code> is set to a<a href="glib-Key-value-file-parser.html#GKeyFileError"><span class="type">GKeyFileError</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>key_file</code></em> :</span></td><td> an empty <a href="glib-Key-value-file-parser.html#GKeyFile"><span class="type">GKeyFile</span></a> struct</td></tr><tr><td><span class="term"><em class="parameter"><code>data</code></em> :</span></td><td> key file loaded in memory.</td></tr><tr><td><span class="term"><em class="parameter"><code>length</code></em> :</span></td><td> the length of <em class="parameter"><code>data</code></em> in bytes</td></tr><tr><td><span class="term"><em class="parameter"><code>flags</code></em> :</span></td><td> flags from <a href="glib-Key-value-file-parser.html#GKeyFileFlags"><span class="type">GKeyFileFlags</span></a></td></tr><tr><td><span class="term"><em class="parameter"><code>error</code></em> :</span></td><td> return location for a <a href="glib-Error-Reporting.html#GError"><span class="type">GError</span></a>, or <code class="literal">NULL</code></td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> <code class="literal">TRUE</code> if a key file could be loaded, <code class="literal">FALSE</code> othewise</td></tr></tbody></table></div><p>Since 2.6</p></div><hr><div class="refsect2" lang="en"><a name="id3083635"></a><h3><a name="g-key-file-load-from-data-dirs"></a>g_key_file_load_from_data_dirs ()</h3><a class="indexterm" name="id3083645"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gboolean">gboolean</a> g_key_file_load_from_data_dirs (<a href="glib-Key-value-file-parser.html#GKeyFile">GKeyFile</a> *key_file, const <a href="glib-Basic-Types.html#gchar">gchar</a> *file, <a href="glib-Basic-Types.html#gchar">gchar</a> **full_path, <a href="glib-Key-value-file-parser.html#GKeyFileFlags">GKeyFileFlags</a> flags, <a href="glib-Error-Reporting.html#GError">GError</a> **error);</pre><p>This function looks for a key file named <em class="parameter"><code>file</code></em> in the paths returned from <a href="glib-Miscellaneous-Utility-Functions.html#g-get-user-data-dir"><code class="function">g_get_user_data_dir()</code></a> and <a href="glib-Miscellaneous-Utility-Functions.html#g-get-system-data-dirs"><code class="function">g_get_system_data_dirs()</code></a>, loads the file into <em class="parameter"><code>key_file</code></em> and returns the file's full path in <em class="parameter"><code>full_path</code></em>. If the file could not be loaded then an <code class="literal">error</code> isset to either a <a href="glib-File-Utilities.html#GFileError"><span class="type">GFileError</span></a> or <a href="glib-Key-value-file-parser.html#GKeyFileError"><span class="type">GKeyFileError</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>key_file</code></em> :</span></td><td> an empty <a href="glib-Key-value-file-parser.html#GKeyFile"><span class="type">GKeyFile</span></a> struct</td></tr><tr><td><span class="term"><em class="parameter"><code>file</code></em> :</span></td><td> a relative path to a filename to open and parse</td></tr><tr><td><span class="term"><em class="parameter"><code>full_path</code></em> :</span></td><td> return location for a string containing the full path of the file, or <code class="literal">NULL</code></td></tr><tr><td><span class="term"><em class="parameter"><code>flags</code></em> :</span></td><td> flags from <a href="glib-Key-value-file-parser.html#GKeyFileFlags"><span class="type">GKeyFileFlags</span></a> </td></tr><tr><td><span class="term"><em class="parameter"><code>error</code></em> :</span></td><td> return location for a <a href="glib-Error-Reporting.html#GError"><span class="type">GError</span></a>, or <code class="literal">NULL</code></td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> <code class="literal">TRUE</code> if a key file could be loaded, <code class="literal">FALSE</code> othewise</td></tr></tbody></table></div><p>Since 2.6</p></div><hr><div class="refsect2" lang="en"><a name="id3083875"></a><h3><a name="g-key-file-to-data"></a>g_key_file_to_data ()</h3><a class="indexterm" name="id3083883"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gchar">gchar</a>* g_key_file_to_data (<a href="glib-Key-value-file-parser.html#GKeyFile">GKeyFile</a> *key_file, <a href="glib-Basic-Types.html#gsize">gsize</a> *length, <a href="glib-Error-Reporting.html#GError">GError</a> **error);</pre><p>This function outputs <em class="parameter"><code>key_file</code></em> as a string.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>key_file</code></em> :</span></td><td> a <a href="glib-Key-value-file-parser.html#GKeyFile"><span class="type">GKeyFile</span></a></td></tr><tr><td><span class="term"><em class="parameter"><code>length</code></em> :</span></td><td> return location for the length of the returned string, or <code class="literal">NULL</code></td></tr><tr><td><span class="term"><em class="parameter"><code>error</code></em> :</span></td><td> return location for a <a href="glib-Error-Reporting.html#GError"><span class="type">GError</span></a>, 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 allocated string holding the contents of the <a href="glib-Key-value-file-parser.html#GKeyFile"><span class="type">GKeyFile</span></a> </td></tr></tbody></table></div><p>Since 2.6</p></div><hr><div class="refsect2" lang="en"><a name="id3084015"></a><h3><a name="g-key-file-get-start-group"></a>g_key_file_get_start_group ()</h3><a class="indexterm" name="id3084024"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gchar">gchar</a>* g_key_file_get_start_group (<a href="glib-Key-value-file-parser.html#GKeyFile">GKeyFile</a> *key_file);</pre><p>Returns the name of the start group of the file.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>key_file</code></em> :</span></td><td> a <a href="glib-Key-value-file-parser.html#GKeyFile"><span class="type">GKeyFile</span></a></td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> The start group of the key file.</td></tr></tbody></table></div><p>Since 2.6</p></div><hr><div class="refsect2" lang="en"><a name="id3084089"></a><h3><a name="g-key-file-get-groups"></a>g_key_file_get_groups ()</h3><a class="indexterm" name="id3084098"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gchar">gchar</a>** g_key_file_get_groups (<a href="glib-Key-value-file-parser.html#GKeyFile">GKeyFile</a> *key_file, <a href="glib-Basic-Types.html#gsize">gsize</a> *length);</pre><p>Returns all groups in the key file loaded with <em class="parameter"><code>key_file</code></em>. Thearray of returned groups will be <code class="literal">NULL</code>-terminated, so <em class="parameter"><code>length</code></em> mayoptionally be <code class="literal">NULL</code>.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>key_file</code></em> :</span></td><td> a <a href="glib-Key-value-file-parser.html#GKeyFile"><span class="type">GKeyFile</span></a></td></tr><tr><td><span class="term"><em class="parameter"><code>length</code></em> :</span></td><td> return location for the number of returned groups, 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-allocated <code class="literal">NULL</code>-terminated array of strings. Use <a href="glib-String-Utility-Functions.html#g-strfreev"><code class="function">g_strfreev()</code></a> to free it.</td></tr></tbody></table></div><p>Since 2.6</p></div><hr><div class="refsect2" lang="en"><a name="id3084224"></a><h3><a name="g-key-file-get-keys"></a>g_key_file_get_keys ()</h3><a class="indexterm" name="id3084232"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gchar">gchar</a>** g_key_file_get_keys (<a href="glib-Key-value-file-parser.html#GKeyFile">GKeyFile</a> *key_file, const <a href="glib-Basic-Types.html#gchar">gchar</a> *group_name,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -