Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-14 09:11:53

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