1 /* json-reader.h - JSON cursor parser
3 * This file is part of JSON-GLib
4 * Copyright (C) 2010 Intel Corp.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
20 * Emmanuele Bassi <ebassi@linux.intel.com>
23 #if !defined(__JSON_GLIB_INSIDE__) && !defined(JSON_COMPILATION)
24 #error "Only <json-glib/json-glib.h> can be included directly."
27 #ifndef __JSON_READER_H__
28 #define __JSON_READER_H__
30 #include <json-glib/json-types.h>
34 #define JSON_TYPE_READER (json_reader_get_type ())
35 #define JSON_READER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), JSON_TYPE_READER, JsonReader))
36 #define JSON_IS_READER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), JSON_TYPE_READER))
37 #define JSON_READER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), JSON_TYPE_READER, JsonReaderClass))
38 #define JSON_IS_READER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), JSON_TYPE_READER))
39 #define JSON_READER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), JSON_TYPE_READER, JsonReaderClass))
44 * Error domain for #JsonReader errors
48 #define JSON_READER_ERROR (json_reader_error_quark ())
50 typedef struct _JsonReader JsonReader;
51 typedef struct _JsonReaderPrivate JsonReaderPrivate;
52 typedef struct _JsonReaderClass JsonReaderClass;
56 * @JSON_READER_ERROR_NO_ARRAY: No array found at the current position
57 * @JSON_READER_ERROR_INVALID_INDEX: Index out of bounds
58 * @JSON_READER_ERROR_NO_OBJECT: No object found at the current position
59 * @JSON_READER_ERROR_INVALID_MEMBER: Member not found
60 * @JSON_READER_ERROR_INVALID_NODE: No valid node found at the current position
61 * @JSON_READER_ERROR_NO_VALUE: The node at the current position does not
63 * @JSON_READER_ERROR_INVALID_TYPE: The node at the current position does not
64 * hold a value of the desired type
66 * Error codes enumeration for #JsonReader errors
71 JSON_READER_ERROR_NO_ARRAY,
72 JSON_READER_ERROR_INVALID_INDEX,
73 JSON_READER_ERROR_NO_OBJECT,
74 JSON_READER_ERROR_INVALID_MEMBER,
75 JSON_READER_ERROR_INVALID_NODE,
76 JSON_READER_ERROR_NO_VALUE,
77 JSON_READER_ERROR_INVALID_TYPE
83 * The <structname>JsonReader</structname> structure contains only
84 * private data and should only be accessed using the provided API
91 GObject parent_instance;
93 JsonReaderPrivate *priv;
99 * The <structname>JsonReaderClass</structname> structure contains only
104 struct _JsonReaderClass
107 GObjectClass parent_class;
109 void (*_json_padding0) (void);
110 void (*_json_padding1) (void);
111 void (*_json_padding2) (void);
112 void (*_json_padding3) (void);
113 void (*_json_padding4) (void);
116 GQuark json_reader_error_quark (void);
117 GType json_reader_get_type (void) G_GNUC_CONST;
119 JsonReader * json_reader_new (JsonNode *node);
121 void json_reader_set_root (JsonReader *reader,
124 const GError * json_reader_get_error (JsonReader *reader);
126 gboolean json_reader_is_array (JsonReader *reader);
127 gboolean json_reader_read_element (JsonReader *reader,
129 void json_reader_end_element (JsonReader *reader);
130 gint json_reader_count_elements (JsonReader *reader);
132 gboolean json_reader_is_object (JsonReader *reader);
133 gboolean json_reader_read_member (JsonReader *reader,
134 const gchar *member_name);
135 void json_reader_end_member (JsonReader *reader);
136 gint json_reader_count_members (JsonReader *reader);
137 gchar ** json_reader_list_members (JsonReader *reader);
138 const gchar * json_reader_get_member_name (JsonReader *reader);
140 gboolean json_reader_is_value (JsonReader *reader);
141 JsonNode * json_reader_get_value (JsonReader *reader);
142 gint64 json_reader_get_int_value (JsonReader *reader);
143 gdouble json_reader_get_double_value (JsonReader *reader);
144 const gchar * json_reader_get_string_value (JsonReader *reader);
145 gboolean json_reader_get_boolean_value (JsonReader *reader);
146 gboolean json_reader_get_null_value (JsonReader *reader);
150 #endif /* __JSON_READER_H__ */