diff options
-rw-r--r-- | doc/reference/json-glib-sections.txt | 26 | ||||
-rw-r--r-- | json-glib/json-array.c | 22 | ||||
-rw-r--r-- | json-glib/json-node.c | 78 | ||||
-rw-r--r-- | json-glib/json-object.c | 15 | ||||
-rw-r--r-- | json-glib/json-types.h | 2 |
5 files changed, 141 insertions, 2 deletions
diff --git a/doc/reference/json-glib-sections.txt b/doc/reference/json-glib-sections.txt index 932d12d..fcc605b 100644 --- a/doc/reference/json-glib-sections.txt +++ b/doc/reference/json-glib-sections.txt @@ -2,10 +2,12 @@ <FILE>json-object</FILE> <TITLE>JsonObject</TITLE> JsonObject +json_object_new json_object_ref json_object_unref <SUBSECTION> +json_object_add_member json_object_has_member json_object_get_member json_object_get_members @@ -20,10 +22,13 @@ json_object_get_type <FILE>json-array</FILE> <TITLE>JsonArray</TITLE> JsonArray +json_array_new +json_array_sized_new json_array_ref json_array_unref <SUBSECTION> +json_array_add_element json_array_get_element json_array_get_elements json_array_get_length @@ -36,12 +41,30 @@ json_array_get_type <SECTION> <FILE>json-node</FILE> <TITLE>JsonNode</TITLE> -JsonNode JsonNodeType JSON_NODE_TYPE +JsonNode +json_node_new +json_node_copy +json_node_free + +<SUBSECTION> +json_node_set_array +json_node_take_array json_node_get_array +json_node_dup_array + +<SUBSECTION> +json_node_set_object +json_node_take_object json_node_get_object +json_node_dup_object + +<SUBSECTION> +json_node_set_value json_node_get_value + +<SUBSECTION> json_node_get_parent json_node_type_name </SECTION> @@ -92,7 +115,6 @@ JSON_GENERATOR JSON_IS_GENERATOR JSON_GENERATOR_CLASS JSON_IS_GENERATOR_CLASS -JSON_GENERATOR_ERROR JSON_GENERATOR_GET_CLASS <SUBSECTION Private> diff --git a/json-glib/json-array.c b/json-glib/json-array.c index 3de3244..4b17825 100644 --- a/json-glib/json-array.c +++ b/json-glib/json-array.c @@ -44,6 +44,13 @@ struct _JsonArray volatile gint ref_count; }; +/** + * json_array_new: + * + * Creates a new #JsonArray. + * + * Return value: the newly created #JsonArray + */ JsonArray * json_array_new (void) { @@ -57,6 +64,14 @@ json_array_new (void) return array; } +/** + * json_array_sized_new: + * @n_elements: number of slots to pre-allocate + * + * Creates a new #JsonArray with @n_elements slots already allocated. + * + * Return value: the newly created #JsonArray + */ JsonArray * json_array_sized_new (guint n_elements) { @@ -185,6 +200,13 @@ json_array_get_length (JsonArray *array) return array->elements->len; } +/** + * json_array_add_element: + * @array: a #JsonArray + * @node: a #JsonNode + * + * Appends @node inside @array. + */ void json_array_add_element (JsonArray *array, JsonNode *node) diff --git a/json-glib/json-node.c b/json-glib/json-node.c index 0cf1b83..3935782 100644 --- a/json-glib/json-node.c +++ b/json-glib/json-node.c @@ -42,17 +42,36 @@ * they contain. */ +/** + * json_node_new: + * @type: a #JsonNodeType + * + * Creates a new #JsonNode of @type. + * + * Return value: the newly created #JsonNode + */ JsonNode * json_node_new (JsonNodeType type) { JsonNode *data; + g_return_val_if_fail (type >= JSON_NODE_OBJECT && type <= JSON_NODE_NULL, NULL); + data = g_slice_new (JsonNode); data->type = type; return data; } +/** + * json_node_copy: + * @node: a #JsonNode + * + * Copies @node. If the node contains complex data types then the reference + * count of the objects is increased. + * + * Return value: the copied #JsonNode + */ JsonNode * json_node_copy (JsonNode *node) { @@ -84,6 +103,13 @@ json_node_copy (JsonNode *node) return copy; } +/** + * json_node_set_object: + * @node: a #JsonNode + * @object: a #JsonObject + * + * Sets @objects inside @node. The reference count of @object is increased. + */ void json_node_set_object (JsonNode *node, JsonObject *object) @@ -100,6 +126,13 @@ json_node_set_object (JsonNode *node, node->data.object = NULL; } +/** + * json_node_take_object: + * @node: a #JsonNode + * @object: a #JsonObject + * + * Sets @object inside @node. The reference count of @object is not increased. + */ void json_node_take_object (JsonNode *node, JsonObject *object) @@ -134,6 +167,15 @@ json_node_get_object (JsonNode *node) return node->data.object; } +/** + * json_node_dup_object: + * @node: a #JsonNode + * + * Retrieves the #JsonObject inside @node. The reference count of + * the returned object is increased. + * + * Return value: the #JsonObject + */ JsonObject * json_node_dup_object (JsonNode *node) { @@ -146,6 +188,13 @@ json_node_dup_object (JsonNode *node) return NULL; } +/** + * json_node_set_array: + * @node: a #JsonNode + * @array: a #JsonArray + * + * Sets @array inside @node and increases the #JsonArray reference count + */ void json_node_set_array (JsonNode *node, JsonArray *array) @@ -162,6 +211,13 @@ json_node_set_array (JsonNode *node, node->data.array = NULL; } +/** + * json_node_take_array: + * @node: a #JsonNode + * @array: a #JsonArray + * + * Sets @array into @node without increasing the #JsonArray reference count. + */ void json_node_take_array (JsonNode *node, JsonArray *array) @@ -196,6 +252,15 @@ json_node_get_array (JsonNode *node) return node->data.array; } +/** + * json_node_dup_array + * @node: a #JsonNode + * + * Retrieves the #JsonArray stored inside a #JsonNode and returns it + * with its reference count increased by one. + * + * Return value: the #JsonArray with its reference count increased. + */ JsonArray * json_node_dup_array (JsonNode *node) { @@ -230,6 +295,13 @@ json_node_get_value (JsonNode *node, } } +/** + * json_node_set_value: + * @node: a #JsonNode + * @value: the #GValue to set + * + * Sets @value inside @node. The passed #GValue is copied into the #JsonNode + */ void json_node_set_value (JsonNode *node, const GValue *value) @@ -244,6 +316,12 @@ json_node_set_value (JsonNode *node, g_value_copy (value, &(node->data.value)); } +/** + * json_node_free: + * @node: a #JsonNode + * + * Frees the resources allocated by @node. + */ void json_node_free (JsonNode *node) { diff --git a/json-glib/json-object.c b/json-glib/json-object.c index 7423917..96fcdbe 100644 --- a/json-glib/json-object.c +++ b/json-glib/json-object.c @@ -47,6 +47,13 @@ struct _JsonObject volatile gint ref_count; }; +/** + * json_object_new: + * + * Creates a new #JsonObject, an JSON object type representation. + * + * Return value: the newly created #JsonObject + */ JsonObject * json_object_new (void) { @@ -110,6 +117,14 @@ json_object_unref (JsonObject *object) } } +/** + * json_object_add_member: + * @object: a #JsonObject + * @member_name: the name of the member + * @node: the value of the member + * + * Adds a member named @member_name and containing @node into a #JsonObject. + */ void json_object_add_member (JsonObject *object, const gchar *member_name, diff --git a/json-glib/json-types.h b/json-glib/json-types.h index b92c709..3278d3a 100644 --- a/json-glib/json-types.h +++ b/json-glib/json-types.h @@ -112,6 +112,7 @@ void json_node_get_value (JsonNode *node, JsonNode * json_node_get_parent (JsonNode *node); G_CONST_RETURN gchar *json_node_type_name (JsonNode *node); +void json_object_get_type (void) G_GNUC_CONST; JsonObject * json_object_new (void); JsonObject * json_object_ref (JsonObject *object); void json_object_unref (JsonObject *object); @@ -125,6 +126,7 @@ gboolean json_object_has_member (JsonObject *object, const gchar *member_name); guint json_object_get_size (JsonObject *object); +void json_array_get_type (void) G_GNUC_CONST; JsonArray * json_array_new (void); JsonArray * json_array_sized_new (guint n_elements); JsonArray * json_array_ref (JsonArray *array); |