summaryrefslogtreecommitdiff
path: root/json-glib/json-gobject.h
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@linux.intel.com>2009-10-27 17:53:34 +0000
committerEmmanuele Bassi <ebassi@linux.intel.com>2009-10-27 17:53:34 +0000
commitff986ee5b8df45255f4f5ab01be0bbad893bc55e (patch)
tree16d565e41225266c2d762f174d1f238c7c72d2d6 /json-glib/json-gobject.h
parent7f6a73a0964b66b15e8b5a9858b9bc76b010f67b (diff)
downloadjson-glib-ff986ee5b8df45255f4f5ab01be0bbad893bc55e.tar.gz
gobject: Add experimental GBoxed<->JSON transformation
Serializing and deserializing GBoxed types is fairly complicated currently. If a GObject implements JsonSerializable it is possible for the class to intercept the JsonNode, parse it manually and then set the value to the property. This leaves a hole opened for: • manual (de)serialization of GBoxed types • (de)serialization of GBoxed properties in classes not implementing JsonSerializable In order to serialize and deserialize a GBoxed JSON-GLib should provide a mechanism similar to the GValue transformation functions: when registering the boxed type the developer should also be able to register a serialization and a deserialization functions pair matching the tuple: (GBoxed type, JSON type) The serialization function would be: JsonNode *(* JsonBoxedSerializeFunc) (gconstpointer boxed); And, conversely, the deserialization function would be: gpointer (* JsonBoxedDeserializeFunc) (JsonNode *node); Obviously, the whole machinery works only for GBoxed types that register the serialization and deserialization functions.
Diffstat (limited to 'json-glib/json-gobject.h')
-rw-r--r--json-glib/json-gobject.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/json-glib/json-gobject.h b/json-glib/json-gobject.h
index 8eacc58..207db52 100644
--- a/json-glib/json-gobject.h
+++ b/json-glib/json-gobject.h
@@ -79,6 +79,43 @@ gboolean json_serializable_deserialize_property (JsonSerializable *serializable
GParamSpec *pspec,
JsonNode *property_node);
+/**
+ * JsonBoxedSerializeFunc:
+ * @boxed: a #GBoxed
+ *
+ * Serializes the passed #GBoxed and stores it inside a #JsonNode
+ *
+ * Return value: the newly created #JsonNode
+ *
+ * Since: 0.10
+ */
+typedef JsonNode *(* JsonBoxedSerializeFunc) (gconstpointer boxed);
+
+/**
+ * JsonBoxedDeserializeFunc:
+ * @node: a #JsonNode
+ *
+ * Deserializes the contents of the passed #JsonNode into a #GBoxed
+ *
+ * Return value: the newly created boxed type
+ *
+ * Since: 0.10
+ */
+typedef gpointer (* JsonBoxedDeserializeFunc) (JsonNode *node);
+
+void json_boxed_register_transform_func (GType gboxed_type,
+ JsonNodeType node_type,
+ JsonBoxedSerializeFunc serialize_func,
+ JsonBoxedDeserializeFunc deserialize_func);
+gboolean json_boxed_can_serialize (GType gboxed_type,
+ JsonNodeType *node_type);
+gboolean json_boxed_can_deserialize (GType gboxed_type,
+ JsonNodeType node_type);
+JsonNode *json_boxed_serialize (GType gboxed_type,
+ JsonNodeType node_type,
+ gconstpointer boxed);
+gpointer json_boxed_deserialize (GType gboxed_type,
+ JsonNode *node);
GObject *json_construct_gobject (GType gtype,
const gchar *data,