diff options
| author | Emmanuele Bassi <ebassi@linux.intel.com> | 2009-11-23 22:20:58 +0000 |
|---|---|---|
| committer | Emmanuele Bassi <ebassi@linux.intel.com> | 2009-11-23 22:20:58 +0000 |
| commit | 3cf919e9c7f3201305a1a63a3c270e422a37efed (patch) | |
| tree | 34d263f22b1e25f6557f8ce58c231244c6e0e96f /json-glib/json-gobject.h | |
| parent | 61d54cc9e2a3098e876e700a9248428f400a5368 (diff) | |
| download | json-glib-3cf919e9c7f3201305a1a63a3c270e422a37efed.tar.gz | |
boxed: Split (de)serialization registration
A GBoxed type defined as:
struct Boxed {
int foo;
gboolean bar;
int baz;
};
Can be represented either by a JSON object:
{
"foo" : 1,
"bar" : true,
"baz" : 3
}
Or by a JSON array:
[ 1, true, 3 ]
The current function for registering a serialization and a
deserialization pair does not allow registering more than one
deserialization function - which means that there can only be
one way to deserialize a GBoxed type into a specific JsonNode
type.
To allow having more than one JsonNodeType associated to a
GBoxed type and a deserialization function we need to split out
the registration of the serialization and deserialization functions
into two distinct functions.
Diffstat (limited to 'json-glib/json-gobject.h')
| -rw-r--r-- | json-glib/json-gobject.h | 63 |
1 files changed, 32 insertions, 31 deletions
diff --git a/json-glib/json-gobject.h b/json-glib/json-gobject.h index 69ae4e2..0fde684 100644 --- a/json-glib/json-gobject.h +++ b/json-glib/json-gobject.h @@ -113,39 +113,40 @@ typedef JsonNode *(* JsonBoxedSerializeFunc) (gconstpointer boxed); */ 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); - -JsonNode *json_gobject_serialize (GObject *gobject); -GObject * json_gobject_deserialize (GType gtype, - JsonNode *node); - -GObject * json_gobject_from_data (GType gtype, - const gchar *data, - gssize length, - GError **error); -gchar * json_gobject_to_data (GObject *gobject, - gsize *length); +void json_boxed_register_serialize_func (GType gboxed_type, + JsonNodeType node_type, + JsonBoxedSerializeFunc serialize_func); +void json_boxed_register_deserialize_func (GType gboxed_type, + JsonNodeType node_type, + JsonBoxedDeserializeFunc serialize_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, + gconstpointer boxed); +gpointer json_boxed_deserialize (GType gboxed_type, + JsonNode *node); + +JsonNode *json_gobject_serialize (GObject *gobject); +GObject * json_gobject_deserialize (GType gtype, + JsonNode *node); + +GObject * json_gobject_from_data (GType gtype, + const gchar *data, + gssize length, + GError **error); +gchar * json_gobject_to_data (GObject *gobject, + gsize *length); #ifndef JSON_DISABLE_DEPRECATED -GObject * json_construct_gobject (GType gtype, - const gchar *data, - gsize length, - GError **error) G_GNUC_DEPRECATED; -gchar * json_serialize_gobject (GObject *gobject, - gsize *length) G_GNUC_MALLOC G_GNUC_DEPRECATED; -#endif +GObject * json_construct_gobject (GType gtype, + const gchar *data, + gsize length, + GError **error) G_GNUC_DEPRECATED; +gchar * json_serialize_gobject (GObject *gobject, + gsize *length) G_GNUC_MALLOC G_GNUC_DEPRECATED; +#endif /* JSON_DISABLE_DEPRECATED */ G_END_DECLS |
