[glib/wip/jstpierre/gvfs: 1/2] gkeyfile: Add load_from_string API that is easy to use from GI
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/jstpierre/gvfs: 1/2] gkeyfile: Add load_from_string API that is easy to use from GI
- Date: Fri, 10 Jun 2016 20:53:04 +0000 (UTC)
commit 5322e859b6cb23c2153e6cb0b29d90edba73d766
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Fri Jun 10 13:12:28 2016 -0700
gkeyfile: Add load_from_string API that is easy to use from GI
load_from_data has the issue that it requires you to pass an explicit
length. It would be easy to pass -1, except the argument is unsigned,
and since (gsize) -1 is architecture-dependent, it is near impossible to
use from a language like Python.
docs/reference/glib/glib-sections.txt | 1 +
glib/gkeyfile.c | 23 +++++++++++++++++++++++
glib/gkeyfile.h | 5 +++++
3 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt
index 40024d1..6b1468a 100644
--- a/docs/reference/glib/glib-sections.txt
+++ b/docs/reference/glib/glib-sections.txt
@@ -1925,6 +1925,7 @@ g_key_file_unref
g_key_file_set_list_separator
g_key_file_load_from_file
g_key_file_load_from_data
+g_key_file_load_from_string
g_key_file_load_from_data_dirs
g_key_file_load_from_dirs
g_key_file_to_data
diff --git a/glib/gkeyfile.c b/glib/gkeyfile.c
index 4b25fd7..3514eb6 100644
--- a/glib/gkeyfile.c
+++ b/glib/gkeyfile.c
@@ -927,6 +927,29 @@ g_key_file_load_from_data (GKeyFile *key_file,
}
/**
+ * g_key_file_load_from_string:
+ * @key_file: an empty #GKeyFile struct
+ * @string: key file loaded in memory
+ * @flags: flags from #GKeyFileFlags
+ * @error: return location for a #GError, or %NULL
+ *
+ * Loads a key file from memory into an empty #GKeyFile structure.
+ * If the object cannot be created then %error is set to a #GKeyFileError.
+ *
+ * Returns: %TRUE if a key file could be loaded, %FALSE otherwise
+ *
+ * Since: 2.50
+ **/
+gboolean
+g_key_file_load_from_string (GKeyFile *key_file,
+ const gchar *string,
+ GKeyFileFlags flags,
+ GError **error)
+{
+ return g_key_file_load_from_data (key_file, string, (gsize) -1, flags, error);
+}
+
+/**
* g_key_file_load_from_dirs:
* @key_file: an empty #GKeyFile struct
* @file: (type filename): a relative path to a filename to open and parse
diff --git a/glib/gkeyfile.h b/glib/gkeyfile.h
index 0c8d3e5..eeb879f 100644
--- a/glib/gkeyfile.h
+++ b/glib/gkeyfile.h
@@ -76,6 +76,11 @@ gboolean g_key_file_load_from_data (GKeyFile *key_file,
gsize length,
GKeyFileFlags flags,
GError **error);
+GLIB_AVAILABLE_IN_2_50
+gboolean g_key_file_load_from_string (GKeyFile *key_file,
+ const gchar *string,
+ GKeyFileFlags flags,
+ GError **error);
GLIB_AVAILABLE_IN_ALL
gboolean g_key_file_load_from_dirs (GKeyFile *key_file,
const gchar *file,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]