summaryrefslogtreecommitdiff
path: root/json-glib/json-types.h
diff options
context:
space:
mode:
authorPhilip Withnall <philip.withnall@collabora.co.uk>2016-03-01 15:01:07 +0000
committerEmmanuele Bassi <ebassi@gnome.org>2016-03-01 15:01:07 +0000
commit6ddbc94c9888e5ddcd1cbb15845d2f1b5524b3ed (patch)
treecba11bd7504d1f33e48209d2d67b2fd5f0ef00eb /json-glib/json-types.h
parent1de237a502ceee96df7091c2df4492b8bc08b2c5 (diff)
downloadjson-glib-6ddbc94c9888e5ddcd1cbb15845d2f1b5524b3ed.tar.gz
core: Add JSON node, object, array hashes
Now that these objects can be marked as immutable, it is possible to calculate and cache hash values for each of them. This allows efficient hash-based deduplication of large numbers of JSON nodes, as needed by Walbottle for JSON test vector generation. To complement the new hash functions, each of JsonNode, JsonValue, JsonObject and JsonArray also now have an equal() comparison method. This compares them structurally and recursively, using the definition of equality from the JSON Schema specification, which seems as good as any other. http://json-schema.org/latest/json-schema-core.html#anchor9 https://bugzilla.gnome.org/show_bug.cgi?id=756121 Signed-off-by: Emmanuele Bassi <ebassi@gnome.org>
Diffstat (limited to 'json-glib/json-types.h')
-rw-r--r--json-glib/json-types.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/json-glib/json-types.h b/json-glib/json-types.h
index 33180b4..ae5c4f7 100644
--- a/json-glib/json-types.h
+++ b/json-glib/json-types.h
@@ -285,6 +285,21 @@ JSON_AVAILABLE_IN_1_2
void json_node_seal (JsonNode *node);
gboolean json_node_is_immutable (JsonNode *node);
+JSON_AVAILABLE_IN_1_2
+guint json_string_hash (gconstpointer key);
+JSON_AVAILABLE_IN_1_2
+gboolean json_string_equal (gconstpointer a,
+ gconstpointer b);
+JSON_AVAILABLE_IN_1_2
+gint json_string_compare (gconstpointer a,
+ gconstpointer b);
+
+JSON_AVAILABLE_IN_1_2
+guint json_node_hash (gconstpointer key);
+JSON_AVAILABLE_IN_1_2
+gboolean json_node_equal (gconstpointer a,
+ gconstpointer b);
+
/*
* JsonObject
*/
@@ -382,6 +397,12 @@ void json_object_seal (JsonObject *object);
JSON_AVAILABLE_IN_1_2
gboolean json_object_is_immutable (JsonObject *object);
+JSON_AVAILABLE_IN_1_2
+guint json_object_hash (gconstpointer key);
+JSON_AVAILABLE_IN_1_2
+gboolean json_object_equal (gconstpointer a,
+ gconstpointer b);
+
/**
* JsonObjectIter:
*
@@ -486,6 +507,12 @@ void json_array_seal (JsonArray *array);
JSON_AVAILABLE_IN_1_2
gboolean json_array_is_immutable (JsonArray *array);
+JSON_AVAILABLE_IN_1_2
+guint json_array_hash (gconstpointer key);
+JSON_AVAILABLE_IN_1_2
+gboolean json_array_equal (gconstpointer a,
+ gconstpointer b);
+
#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
G_DEFINE_AUTOPTR_CLEANUP_FUNC (JsonArray, json_array_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (JsonObject, json_object_unref)