[glib] Bug 620350 - add g_variant_builder_add_parsed()
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Bug 620350 - add g_variant_builder_add_parsed()
- Date: Thu, 3 Jun 2010 09:25:59 +0000 (UTC)
commit 9562726f35b3e19d5d50d4e2e01bd8c37c7727ab
Author: Ryan Lortie <desrt desrt ca>
Date: Thu Jun 3 11:24:31 2010 +0200
Bug 620350 - add g_variant_builder_add_parsed()
A delicious blend of g_variant_new_parsed() and
g_variant_builder_add_value(). Now available in a GLib near you.
docs/reference/glib/glib-sections.txt | 1 +
glib/glib.symbols | 1 +
glib/gvariant-parser.c | 44 +++++++++++++++++++++++++++++++++
glib/gvariant.h | 3 ++
4 files changed, 49 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt
index cdd0a2e..2e9f8f0 100644
--- a/docs/reference/glib/glib-sections.txt
+++ b/docs/reference/glib/glib-sections.txt
@@ -2900,6 +2900,7 @@ g_variant_builder_init
g_variant_builder_clear
g_variant_builder_add_value
g_variant_builder_add
+g_variant_builder_add_parsed
g_variant_builder_end
g_variant_builder_open
g_variant_builder_close
diff --git a/glib/glib.symbols b/glib/glib.symbols
index f197a6d..cb1318f 100644
--- a/glib/glib.symbols
+++ b/glib/glib.symbols
@@ -1811,6 +1811,7 @@ g_variant_byteswap
#if IN_FILE(__G_VARIANT_PARSER_C__)
g_variant_new_parsed
g_variant_new_parsed_va
+g_variant_builder_add_parsed
g_variant_parse
g_variant_parser_get_error_quark
#endif
diff --git a/glib/gvariant-parser.c b/glib/gvariant-parser.c
index 9bca95f..3533cbe 100644
--- a/glib/gvariant-parser.c
+++ b/glib/gvariant-parser.c
@@ -2248,5 +2248,49 @@ g_variant_new_parsed (const gchar *format,
return result;
}
+/**
+ * g_variant_builder_add_parsed:
+ * @builder: a #GVariantBuilder
+ * @format: a text format #GVariant
+ * @...: arguments as per @format
+ *
+ * Adds to a #GVariantBuilder.
+ *
+ * This call is a convenience wrapper that is exactly equivalent to
+ * calling g_variant_new_parsed() followed by
+ * g_variant_builder_add_value().
+ *
+ * This function might be used as follows:
+ *
+ * <programlisting>
+ * GVariant *
+ * make_pointless_dictionary (void)
+ * {
+ * GVariantBuilder *builder;
+ * int i;
+ *
+ * builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
+ * g_variant_builder_add_parsed (builder, "{'width', <%i>}", 600);
+ * g_variant_builder_add_parsed (builder, "{'title', <%s>}", "foo");
+ * g_variant_builder_add_parsed (builder, "{'transparency', <0.5>}");
+ * return g_variant_builder_end (builder);
+ * }
+ * </programlisting>
+ *
+ * Since: 2.26
+ **/
+void
+g_variant_builder_add_parsed (GVariantBuilder *builder,
+ const gchar *format,
+ ...)
+{
+ va_list ap;
+
+ va_start (ap, format);
+ g_variant_builder_add_value (builder, g_variant_new_parsed_va (format, ap));
+ va_end (ap);
+}
+
+
#define __G_VARIANT_PARSER_C__
#include "galiasdef.c"
diff --git a/glib/gvariant.h b/glib/gvariant.h
index 92692e8..e4a80c0 100644
--- a/glib/gvariant.h
+++ b/glib/gvariant.h
@@ -197,6 +197,9 @@ void g_variant_builder_add_value (GVarian
void g_variant_builder_add (GVariantBuilder *builder,
const gchar *format_string,
...);
+void g_variant_builder_add_parsed (GVariantBuilder *builder,
+ const gchar *format,
+ ...);
GVariant * g_variant_new (const gchar *format_string,
...);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]