37
37
extern "C" {
38
38
#endif
39
39
40
- /** possible data types that a yajl_val_s can hold */
40
+ /** Possible data types that a yajl_val_s can hold */
41
41
typedef enum {
42
42
yajl_t_string = 1 ,
43
43
yajl_t_number = 2 ,
@@ -99,33 +99,33 @@ struct yajl_val_s
99
99
/**
100
100
* Parse a string.
101
101
*
102
- * Parses an null -terminated string containing JSON data and returns a pointer
102
+ * Parses a zero -terminated string containing JSON5 data and returns a pointer
103
103
* to the top-level value (root of the parse tree).
104
104
*
105
105
* \param input Pointer to a null-terminated utf8 string containing
106
- * JSON data.
106
+ * JSON or JSON5 data.
107
107
* \param error_buffer Pointer to a buffer in which an error message will
108
- * be stored if \em yajl_tree_parse fails, or
108
+ * be stored if yajl_tree_parse() fails, or
109
109
* \c NULL. The buffer will be initialized before
110
110
* parsing, so its content will be destroyed even if
111
- * \em yajl_tree_parse succeeds.
111
+ * yajl_tree_parse() succeeds.
112
112
* \param error_buffer_size Size of the memory area pointed to by
113
- * \em error_buffer_size . If \em error_buffer_size is
114
- * \c NULL, this argument is ignored.
113
+ * \p error_buffer . If \p error_buffer
114
+ * is \c NULL, this argument is ignored.
115
115
*
116
116
* \returns Pointer to the top-level value or \c NULL on error. The memory
117
- * pointed to must be freed using \em yajl_tree_free. In case of an error, a
118
- * null terminated message describing the error in more detail is stored in
119
- * \em error_buffer if it is not \c NULL.
117
+ * pointed to must be freed using yajl_tree_free() . In case of an error, a
118
+ * zero- terminated message describing the error in more detail is stored in
119
+ * \p error_buffer if it is not \c NULL.
120
120
*/
121
121
YAJL_API yajl_val yajl_tree_parse (const char * input ,
122
122
char * error_buffer , size_t error_buffer_size );
123
123
124
124
125
125
/**
126
- * Free a parse tree returned by " yajl_tree_parse" .
126
+ * Free a parse tree returned by yajl_tree_parse() .
127
127
*
128
- * \param v Pointer to a JSON value returned by " yajl_tree_parse" . Passing NULL
128
+ * \param v Pointer to a JSON value returned by yajl_tree_parse() . Passing \c NULL
129
129
* is valid and results in a no-op.
130
130
*/
131
131
YAJL_API void yajl_tree_free (yajl_val v );
@@ -134,10 +134,10 @@ YAJL_API void yajl_tree_free (yajl_val v);
134
134
* Access a nested value inside a tree.
135
135
*
136
136
* \param parent the node under which you'd like to extract values.
137
- * \param path A null terminated array of strings, each the name of an object key
138
- * \param type the yajl_type of the object you seek, or yajl_t_any if any will do.
137
+ * \param path A null terminated array of strings, each the name of an object key.
138
+ * \param type the \ref yajl_type of the object you seek, or \ref yajl_t_any if any will do.
139
139
*
140
- * \returns a pointer to the found value, or NULL if we came up empty.
140
+ * \returns a pointer to the found value, or \c NULL if we came up empty.
141
141
*
142
142
* Future Ideas: it'd be nice to move path to a string and implement support for
143
143
* a teeny tiny micro language here, so you can extract array elements, do things
@@ -146,7 +146,11 @@ YAJL_API void yajl_tree_free (yajl_val v);
146
146
*/
147
147
YAJL_API yajl_val yajl_tree_get (yajl_val parent , const char * * path , yajl_type type );
148
148
149
- /* Various convenience macros to check the type of a `yajl_val` */
149
+ /** @name Type Check Macros
150
+ *
151
+ * Convenience macros to check the type of a \ref yajl_val.
152
+ */
153
+ /**@{*/
150
154
#define YAJL_IS_STRING (v ) (((v) != NULL) && ((v)->type == yajl_t_string))
151
155
#define YAJL_IS_NUMBER (v ) (((v) != NULL) && ((v)->type == yajl_t_number))
152
156
#define YAJL_IS_INTEGER (v ) (YAJL_IS_NUMBER(v) && ((v)->u.number.flags & YAJL_NUMBER_INT_VALID))
@@ -156,29 +160,38 @@ YAJL_API yajl_val yajl_tree_get(yajl_val parent, const char ** path, yajl_type t
156
160
#define YAJL_IS_TRUE (v ) (((v) != NULL) && ((v)->type == yajl_t_true ))
157
161
#define YAJL_IS_FALSE (v ) (((v) != NULL) && ((v)->type == yajl_t_false ))
158
162
#define YAJL_IS_NULL (v ) (((v) != NULL) && ((v)->type == yajl_t_null ))
163
+ /**@}*/
164
+
165
+ /** @name Value Get Macros
166
+ *
167
+ * Macros to fetch values from a \ref yajl_val.
168
+ */
169
+ /**@{*/
159
170
160
- /** Given a yajl_val_string return a ptr to the bare string it contains,
161
- * or NULL if the value is not a string. */
171
+ /** Given a \ref yajl_t_string return a ptr to the bare string it contains,
172
+ * or \c NULL if the value is not a string. */
162
173
#define YAJL_GET_STRING (v ) (YAJL_IS_STRING(v) ? (v)->u.string : NULL)
163
174
164
175
/** Get the string representation of a number. You should check type first,
165
- * perhaps using YAJL_IS_NUMBER */
176
+ * perhaps using \ref YAJL_IS_NUMBER */
166
177
#define YAJL_GET_NUMBER (v ) ((v)->u.number.r)
167
178
168
179
/** Get the double representation of a number. You should check type first,
169
- * perhaps using YAJL_IS_DOUBLE */
180
+ * perhaps using \ref YAJL_IS_DOUBLE */
170
181
#define YAJL_GET_DOUBLE (v ) ((v)->u.number.d)
171
182
172
183
/** Get the 64bit (long long) integer representation of a number. You should
173
- * check type first, perhaps using YAJL_IS_INTEGER */
184
+ * check type first, perhaps using \ref YAJL_IS_INTEGER */
174
185
#define YAJL_GET_INTEGER (v ) ((v)->u.number.i)
175
186
176
- /** Get a pointer to a yajl_val_object or NULL if the value is not an object. */
187
+ /** Get a pointer to a \ref yajl_t_object or \c NULL if the value is not an object. */
177
188
#define YAJL_GET_OBJECT (v ) (YAJL_IS_OBJECT(v) ? &(v)->u.object : NULL)
178
189
179
- /** Get a pointer to a yajl_val_array or NULL if the value is not an object. */
190
+ /** Get a pointer to a \ref yajl_t_array or \c NULL if the value is not an object. */
180
191
#define YAJL_GET_ARRAY (v ) (YAJL_IS_ARRAY(v) ? &(v)->u.array : NULL)
181
192
193
+ /**@}*/
194
+
182
195
#ifdef __cplusplus
183
196
}
184
197
#endif
0 commit comments