Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:01:42

0001 /* json-reader.h - JSON cursor parser
0002  * 
0003  * This file is part of JSON-GLib
0004  * Copyright (C) 2010  Intel Corp.
0005  *
0006  * This library is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU Lesser General Public
0008  * License as published by the Free Software Foundation; either
0009  * version 2.1 of the License, or (at your option) any later version.
0010  *
0011  * This library is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  * Lesser General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU Lesser General Public
0017  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
0018  *
0019  * Author:
0020  *   Emmanuele Bassi  <ebassi@linux.intel.com>
0021  */
0022 
0023 #ifndef __JSON_READER_H__
0024 #define __JSON_READER_H__
0025 
0026 #if !defined(__JSON_GLIB_INSIDE__) && !defined(JSON_COMPILATION)
0027 #error "Only <json-glib/json-glib.h> can be included directly."
0028 #endif
0029 
0030 #include <json-glib/json-types.h>
0031 
0032 G_BEGIN_DECLS
0033 
0034 #define JSON_TYPE_READER                (json_reader_get_type ())
0035 #define JSON_READER(obj)                (G_TYPE_CHECK_INSTANCE_CAST ((obj), JSON_TYPE_READER, JsonReader))
0036 #define JSON_IS_READER(obj)             (G_TYPE_CHECK_INSTANCE_TYPE ((obj), JSON_TYPE_READER))
0037 #define JSON_READER_CLASS(klass)        (G_TYPE_CHECK_CLASS_CAST ((klass), JSON_TYPE_READER, JsonReaderClass))
0038 #define JSON_IS_READER_CLASS(klass)     (G_TYPE_CHECK_CLASS_TYPE ((klass), JSON_TYPE_READER))
0039 #define JSON_READER_GET_CLASS(obj)      (G_TYPE_INSTANCE_GET_CLASS ((obj), JSON_TYPE_READER, JsonReaderClass))
0040 
0041 /**
0042  * JSON_READER_ERROR:
0043  *
0044  * Error domain for `JsonReader`.
0045  *
0046  * Since: 0.12
0047  */
0048 #define JSON_READER_ERROR               (json_reader_error_quark ())
0049 
0050 typedef struct _JsonReader              JsonReader;
0051 typedef struct _JsonReaderPrivate       JsonReaderPrivate;
0052 typedef struct _JsonReaderClass         JsonReaderClass;
0053 
0054 /**
0055  * JsonReaderError:
0056  * @JSON_READER_ERROR_NO_ARRAY: No array found at the current position
0057  * @JSON_READER_ERROR_INVALID_INDEX: Index out of bounds
0058  * @JSON_READER_ERROR_NO_OBJECT: No object found at the current position
0059  * @JSON_READER_ERROR_INVALID_MEMBER: Member not found
0060  * @JSON_READER_ERROR_INVALID_NODE: No valid node found at the current position
0061  * @JSON_READER_ERROR_NO_VALUE: The node at the current position does not
0062  *   hold a value
0063  * @JSON_READER_ERROR_INVALID_TYPE: The node at the current position does not
0064  *   hold a value of the desired type
0065  *
0066  * Error codes for `JSON_READER_ERROR`.
0067  *
0068  * This enumeration can be extended at later date
0069  *
0070  * Since: 0.12
0071  */
0072 typedef enum {
0073   JSON_READER_ERROR_NO_ARRAY,
0074   JSON_READER_ERROR_INVALID_INDEX,
0075   JSON_READER_ERROR_NO_OBJECT,
0076   JSON_READER_ERROR_INVALID_MEMBER,
0077   JSON_READER_ERROR_INVALID_NODE,
0078   JSON_READER_ERROR_NO_VALUE,
0079   JSON_READER_ERROR_INVALID_TYPE
0080 } JsonReaderError;
0081 
0082 struct _JsonReader
0083 {
0084   /*< private >*/
0085   GObject parent_instance;
0086 
0087   JsonReaderPrivate *priv;
0088 };
0089 
0090 struct _JsonReaderClass
0091 {
0092   /*< private >*/
0093   GObjectClass parent_class;
0094 
0095   void (*_json_padding0) (void);
0096   void (*_json_padding1) (void);
0097   void (*_json_padding2) (void);
0098   void (*_json_padding3) (void);
0099   void (*_json_padding4) (void);
0100 };
0101 
0102 JSON_AVAILABLE_IN_1_0
0103 GQuark json_reader_error_quark (void);
0104 JSON_AVAILABLE_IN_1_0
0105 GType json_reader_get_type (void) G_GNUC_CONST;
0106 
0107 JSON_AVAILABLE_IN_1_0
0108 JsonReader *           json_reader_new               (JsonNode     *node);
0109 
0110 JSON_AVAILABLE_IN_1_0
0111 void                   json_reader_set_root          (JsonReader   *reader,
0112                                                       JsonNode     *root);
0113 
0114 JSON_AVAILABLE_IN_1_0
0115 const GError *         json_reader_get_error         (JsonReader   *reader);
0116 
0117 JSON_AVAILABLE_IN_1_0
0118 gboolean               json_reader_is_array          (JsonReader   *reader);
0119 JSON_AVAILABLE_IN_1_0
0120 gboolean               json_reader_read_element      (JsonReader   *reader,
0121                                                       guint         index_);
0122 JSON_AVAILABLE_IN_1_0
0123 void                   json_reader_end_element       (JsonReader   *reader);
0124 JSON_AVAILABLE_IN_1_0
0125 gint                   json_reader_count_elements    (JsonReader   *reader);
0126 
0127 JSON_AVAILABLE_IN_1_0
0128 gboolean               json_reader_is_object         (JsonReader   *reader);
0129 JSON_AVAILABLE_IN_1_0
0130 gboolean               json_reader_read_member       (JsonReader   *reader,
0131                                                       const gchar  *member_name);
0132 JSON_AVAILABLE_IN_1_0
0133 void                   json_reader_end_member        (JsonReader   *reader);
0134 JSON_AVAILABLE_IN_1_0
0135 gint                   json_reader_count_members     (JsonReader   *reader);
0136 JSON_AVAILABLE_IN_1_0
0137 gchar **               json_reader_list_members      (JsonReader   *reader);
0138 JSON_AVAILABLE_IN_1_0
0139 const gchar *          json_reader_get_member_name   (JsonReader   *reader);
0140 
0141 JSON_AVAILABLE_IN_1_0
0142 gboolean               json_reader_is_value          (JsonReader   *reader);
0143 JSON_AVAILABLE_IN_1_0
0144 JsonNode *             json_reader_get_value         (JsonReader   *reader);
0145 JSON_AVAILABLE_IN_1_0
0146 gint64                 json_reader_get_int_value     (JsonReader   *reader);
0147 JSON_AVAILABLE_IN_1_0
0148 gdouble                json_reader_get_double_value  (JsonReader   *reader);
0149 JSON_AVAILABLE_IN_1_0
0150 const gchar *          json_reader_get_string_value  (JsonReader   *reader);
0151 JSON_AVAILABLE_IN_1_0
0152 gboolean               json_reader_get_boolean_value (JsonReader   *reader);
0153 JSON_AVAILABLE_IN_1_0
0154 gboolean               json_reader_get_null_value    (JsonReader   *reader);
0155 
0156 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
0157 G_DEFINE_AUTOPTR_CLEANUP_FUNC (JsonReader, g_object_unref)
0158 #endif
0159 
0160 G_END_DECLS
0161 
0162 #endif /* __JSON_READER_H__ */