diff options
author | Emmanuele Bassi <ebassi@openedhand.com> | 2007-10-01 16:16:15 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@openedhand.com> | 2007-10-01 16:16:15 +0100 |
commit | 29feafc236f888021b817fdfe0cfe685f5e3b65e (patch) | |
tree | bc3931f2746d66cf23c4692a3d56d54c6e8cee0c | |
parent | 6eb1a5e94957d3555e7de5f6744a8777cd89efaf (diff) | |
download | json-glib-29feafc236f888021b817fdfe0cfe685f5e3b65e.tar.gz |
Add licensing informations to the source code
-rw-r--r-- | json-glib/json-array.c | 29 | ||||
-rw-r--r-- | json-glib/json-node.c | 52 | ||||
-rw-r--r-- | json-glib/json-object.c | 34 | ||||
-rw-r--r-- | json-glib/json-parser.c | 28 | ||||
-rw-r--r-- | json-glib/json-parser.h | 19 | ||||
-rw-r--r-- | json-glib/json-types.h | 35 | ||||
-rw-r--r-- | json-glib/json-version.h.in | 19 |
7 files changed, 202 insertions, 14 deletions
diff --git a/json-glib/json-array.c b/json-glib/json-array.c index 2f0a249..7d0973f 100644 --- a/json-glib/json-array.c +++ b/json-glib/json-array.c @@ -1,3 +1,22 @@ +/* json-array.c - JSON array implementation + * + * This file is part of JSON-GLib + * Copyright (C) 2007 OpenedHand Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * Author: + * Emmanuele Bassi <ebassi@openedhand.com> + */ + #include "config.h" #include "json-types.h" @@ -7,6 +26,16 @@ * SECTION:json-array * @short_description: a JSON array representation * + * #JsonArray is the representation of the array type inside JSON. It contains + * #JsonNode<!-- -->s, which may contain fundamental types, other arrays or + * objects. + * + * Since arrays can be expensive, they are reference counted. You can control + * the lifetime of a #JsonArray using json_array_ref() and json_array_unref(). + * + * To extract an element at a given index, use json_array_get_element(). + * To retrieve the entire array in list form, use json_array_get_elements(). + * To retrieve the length of the array, use json_array_get_length(). */ struct _JsonArray diff --git a/json-glib/json-node.c b/json-glib/json-node.c index 465357e..2758585 100644 --- a/json-glib/json-node.c +++ b/json-glib/json-node.c @@ -1,6 +1,32 @@ +/* json-node.c - JSON object model node + * + * This file is part of JSON-GLib + * Copyright (C) 2007 OpenedHand Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * Author: + * Emmanuele Bassi <ebassi@openedhand.com> + */ + +#include "config.h" + +#include <glib.h> + +#include "json-types.h" +#include "json-private.h" + /** * SECTION:json-node - * @short_description: Base element in a JSON stream + * @short_description: Node in a JSON object model * * A #JsonNode is a generic container of elements inside a JSON stream. * It can contain fundamental types (integers, booleans, floating point @@ -17,13 +43,6 @@ * they contain. */ -#include "config.h" - -#include <glib.h> - -#include "json-types.h" -#include "json-private.h" - JsonNode * json_node_new (JsonNodeType type) { @@ -190,6 +209,14 @@ json_node_dup_array (JsonNode *node) return NULL; } +/** + * json_node_get_value: + * @node: a #JsonNode + * @value: return location for an uninitialized value + * + * Retrieves a value from a #JsonNode and copies into @value. When done + * using it, call g_value_unset() on the #GValue. + */ void json_node_get_value (JsonNode *node, GValue *value) @@ -245,6 +272,15 @@ json_node_free (JsonNode *node) } } +/** + * json_node_type_name: + * @node: a #JsonNode + * + * Retrieves the user readable name of the data type contained by @node. + * + * Return value: a string containing the name of the type. The returned string + * is owned by the node and should never be modified or freed + */ G_CONST_RETURN gchar * json_node_type_name (JsonNode *node) { diff --git a/json-glib/json-object.c b/json-glib/json-object.c index 0aa7855..df2591a 100644 --- a/json-glib/json-object.c +++ b/json-glib/json-object.c @@ -1,3 +1,22 @@ +/* json-object.c - JSON object implementation + * + * This file is part of JSON-GLib + * Copyright (C) 2007 OpenedHand Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * Author: + * Emmanuele Bassi <ebassi@openedhand.com> + */ + #include "config.h" #include <glib.h> @@ -9,10 +28,17 @@ * SECTION:json-object * @short_description: a JSON object representation * - * #JsonObject is a boxed type representing a JSON object data type. Each - * JSON object can have zero or more members, and each member is accessed - * by name. Each member can contain different values: numbers, strings, - * arrays (see + * #JsonArray is the representation of the object type inside JSON. It contains + * #JsonNode<!-- -->s, which may contain fundamental types, arrays or other + * objects. Each member of an object is accessed using its name. + * + * Since objects can be expensive, they are reference counted. You can control + * the lifetime of a #JsonObject using json_object_ref() and json_object_unref(). + * + * To extract a member with a given name, use json_object_get_member(). + * To retrieve the list of members, use json_object_get_members(). + * To retrieve the size of the object (that is, the number of members it has), use + * json_object_get_size(). */ struct _JsonObject diff --git a/json-glib/json-parser.c b/json-glib/json-parser.c index 51f23e1..2a4aab6 100644 --- a/json-glib/json-parser.c +++ b/json-glib/json-parser.c @@ -1,7 +1,28 @@ +/* json-parser.c - JSON streams parser + * + * This file is part of JSON-GLib + * Copyright (C) 2007 OpenedHand Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * Author: + * Emmanuele Bassi <ebassi@openedhand.com> + */ + /** * SECTION:json-parser * @short_description: Parse JSON data streams * + * #JsonParser provides an object for parsing a JSON data stream, either + * inside a file or inside a static buffer. */ #include "config.h" @@ -586,7 +607,8 @@ json_parser_new (void) * @filename: the path for the file to parse * @error: return location for a #GError, or %NULL * - * Loads a JSON stream from the content of @filename and parses it. + * Loads a JSON stream from the content of @filename and parses it. See + * json_parser_load_from_data(). * * Return value: %TRUE if the file was successfully loaded and parsed. * In case of error, @error is set accordingly and %FALSE is returned @@ -629,7 +651,9 @@ json_parser_load_from_file (JsonParser *parser, * @length: the length of the buffer, or -1 * @error: return location for a #GError, or %NULL * - * Loads a JSON stream from a buffer and parses it. + * Loads a JSON stream from a buffer and parses it. You can call this function + * multiple times with the same #JsonParser object, but the contents of the + * parser will be destroyed each time. * * Return value: %TRUE if the buffer was succesfully parser. In case * of error, @error is set accordingly and %FALSE is returned diff --git a/json-glib/json-parser.h b/json-glib/json-parser.h index 2b2152b..9c9afb7 100644 --- a/json-glib/json-parser.h +++ b/json-glib/json-parser.h @@ -1,3 +1,22 @@ +/* json-parser.h - JSON streams parser + * + * This file is part of JSON-GLib + * Copyright (C) 2007 OpenedHand Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * Author: + * Emmanuele Bassi <ebassi@openedhand.com> + */ + #ifndef __JSON_PARSER_H__ #define __JSON_PARSER_H__ diff --git a/json-glib/json-types.h b/json-glib/json-types.h index 0cacec3..9578b1c 100644 --- a/json-glib/json-types.h +++ b/json-glib/json-types.h @@ -1,3 +1,22 @@ +/* json-types.h - JSON data types + * + * This file is part of JSON-GLib + * Copyright (C) 2007 OpenedHand Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * Author: + * Emmanuele Bassi <ebassi@openedhand.com> + */ + #ifndef __JSON_TYPES_H__ #define __JSON_TYPES_H__ @@ -13,6 +32,15 @@ typedef struct _JsonObject JsonObject; typedef struct _JsonArray JsonArray; typedef struct _JsonNode JsonNode; +/** + * JsonNodeType: + * @JSON_NODE_OBJECT: The node contains a #JsonObject + * @JSON_NODE_ARRAY: The node contains a #JsonArray + * @JSON_NODE_VALUE: The node contains a #GValue + * @JSON_NODE_NULL: Special type, for nodes containing %NULL + * + * Indicates the content of a #JsonNode. + */ typedef enum { JSON_NODE_OBJECT, JSON_NODE_ARRAY, @@ -20,6 +48,13 @@ typedef enum { JSON_NODE_NULL } JsonNodeType; +/** + * JsonNode: + * + * A generic container of JSON data types. The contents of the #JsonNode + * structure are private and should only be accessed via the provided + * functions and never directly. + */ struct _JsonNode { /*< private >*/ diff --git a/json-glib/json-version.h.in b/json-glib/json-version.h.in index a5af6c1..1057da3 100644 --- a/json-glib/json-version.h.in +++ b/json-glib/json-version.h.in @@ -1,3 +1,22 @@ +/* json-version.h - JSON-GLib versioning information + * + * This file is part of JSON-GLib + * Copyright (C) 2007 OpenedHand Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * Author: + * Emmanuele Bassi <ebassi@openedhand.com> + */ + #ifndef __JSON_VERSION_H__ #define __JSON_VERSION_H__ |