Sun, 15 Dec 2024 15:46:51 +0100
fix wrong "variant" of zero/NULL/false
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1 | /* |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
3 | * |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
4 | * Copyright 2024 Mike Becker, Olaf Wintermann All rights reserved. |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
5 | * |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
6 | * Redistribution and use in source and binary forms, with or without |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
7 | * modification, are permitted provided that the following conditions are met: |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
8 | * |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
9 | * 1. Redistributions of source code must retain the above copyright |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
10 | * notice, this list of conditions and the following disclaimer. |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
11 | * |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
13 | * notice, this list of conditions and the following disclaimer in the |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
14 | * documentation and/or other materials provided with the distribution. |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
15 | * |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
26 | * POSSIBILITY OF SUCH DAMAGE. |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
27 | */ |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
28 | /** |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
29 | * \file json.h |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
30 | * \brief Interface for parsing data from JSON files. |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
31 | * \author Mike Becker |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
32 | * \author Olaf Wintermann |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
33 | * \copyright 2-Clause BSD License |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
34 | */ |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
35 | |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
36 | #ifndef UCX_JSON_H |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
37 | #define UCX_JSON_H |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
38 | |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
39 | #include "common.h" |
996
333155f234c4
add support for allocators to the json parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
988
diff
changeset
|
40 | #include "allocator.h" |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
41 | #include "string.h" |
1007
81b2986d2b04
fix that cxBufferSeek() cannot move pos past the end - fixes #523
Mike Becker <universe@uap-core.de>
parents:
1002
diff
changeset
|
42 | #include "buffer.h" |
967
a58f602ed2fe
simplify parsing of array and object elements
Mike Becker <universe@uap-core.de>
parents:
966
diff
changeset
|
43 | #include "array_list.h" |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
44 | |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
45 | #ifdef __cplusplus |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
46 | extern "C" { |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
47 | #endif |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
48 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
49 | |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
50 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
51 | * The type of the parsed token. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
52 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
53 | enum cx_json_token_type { |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
54 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
55 | * No complete token parsed, yet. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
56 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
57 | CX_JSON_NO_TOKEN, |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
58 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
59 | * The presumed token contains syntactical errors. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
60 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
61 | CX_JSON_TOKEN_ERROR, |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
62 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
63 | * A "begin of array" '[' token. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
64 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
65 | CX_JSON_TOKEN_BEGIN_ARRAY, |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
66 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
67 | * A "begin of object" '{' token. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
68 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
69 | CX_JSON_TOKEN_BEGIN_OBJECT, |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
70 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
71 | * An "end of array" ']' token. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
72 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
73 | CX_JSON_TOKEN_END_ARRAY, |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
74 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
75 | * An "end of object" '}' token. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
76 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
77 | CX_JSON_TOKEN_END_OBJECT, |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
78 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
79 | * A colon ':' token separating names and values. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
80 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
81 | CX_JSON_TOKEN_NAME_SEPARATOR, |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
82 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
83 | * A comma ',' token separating object entries or array elements. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
84 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
85 | CX_JSON_TOKEN_VALUE_SEPARATOR, |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
86 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
87 | * A string token. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
88 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
89 | CX_JSON_TOKEN_STRING, |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
90 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
91 | * A number token that can be represented as integer. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
92 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
93 | CX_JSON_TOKEN_INTEGER, |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
94 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
95 | * A number token that cannot be represented as integer. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
96 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
97 | CX_JSON_TOKEN_NUMBER, |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
98 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
99 | * A literal token. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
100 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
101 | CX_JSON_TOKEN_LITERAL, |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
102 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
103 | * A white-space token. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
104 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
105 | CX_JSON_TOKEN_SPACE |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
106 | }; |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
107 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
108 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
109 | * The type of some JSON value. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
110 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
111 | enum cx_json_value_type { |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
112 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
113 | * Reserved. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
114 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
115 | CX_JSON_NOTHING, // this allows us to always return non-NULL values |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
116 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
117 | * A JSON object. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
118 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
119 | CX_JSON_OBJECT, |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
120 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
121 | * A JSON array. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
122 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
123 | CX_JSON_ARRAY, |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
124 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
125 | * A string. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
126 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
127 | CX_JSON_STRING, |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
128 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
129 | * A number that contains an integer. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
130 | */ |
966
1aa7ec3e46e7
treat integers and doubles both as JSON numbers
Mike Becker <universe@uap-core.de>
parents:
965
diff
changeset
|
131 | CX_JSON_INTEGER, |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
132 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
133 | * A number, not necessarily an integer. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
134 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
135 | CX_JSON_NUMBER, |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
136 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
137 | * A literal (true, false, null). |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
138 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
139 | CX_JSON_LITERAL |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
140 | }; |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
141 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
142 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
143 | * JSON literal types. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
144 | */ |
965
dfdfedbe2c86
remove single-member structs
Mike Becker <universe@uap-core.de>
parents:
954
diff
changeset
|
145 | enum cx_json_literal { |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
146 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
147 | * The \c null literal. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
148 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
149 | CX_JSON_NULL, |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
150 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
151 | * The \c true literal. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
152 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
153 | CX_JSON_TRUE, |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
154 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
155 | * The \c false literal. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
156 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
157 | CX_JSON_FALSE |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
158 | }; |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
159 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
160 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
161 | * Type alias for the token type enum. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
162 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
163 | typedef enum cx_json_token_type CxJsonTokenType; |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
164 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
165 | * Type alias for the value type enum. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
166 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
167 | typedef enum cx_json_value_type CxJsonValueType; |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
168 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
169 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
170 | * Type alias for the JSON parser interface. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
171 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
172 | typedef struct cx_json_s CxJson; |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
173 | |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
174 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
175 | * Type alias for the token struct. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
176 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
177 | typedef struct cx_json_token_s CxJsonToken; |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
178 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
179 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
180 | * Type alias for the JSON value struct. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
181 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
182 | typedef struct cx_json_value_s CxJsonValue; |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
183 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
184 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
185 | * Type alias for the JSON array struct. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
186 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
187 | typedef struct cx_json_array_s CxJsonArray; |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
188 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
189 | * Type alias for the JSON object struct. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
190 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
191 | typedef struct cx_json_object_s CxJsonObject; |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
192 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
193 | * Type alias for a JSON string. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
194 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
195 | typedef struct cx_mutstr_s CxJsonString; |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
196 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
197 | * Type alias for a number that can be represented as 64-bit signed integer. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
198 | */ |
965
dfdfedbe2c86
remove single-member structs
Mike Becker <universe@uap-core.de>
parents:
954
diff
changeset
|
199 | typedef int64_t CxJsonInteger; |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
200 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
201 | * Type alias for number that is not an integer. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
202 | */ |
965
dfdfedbe2c86
remove single-member structs
Mike Becker <universe@uap-core.de>
parents:
954
diff
changeset
|
203 | typedef double CxJsonNumber; |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
204 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
205 | * Type alias for a JSON literal. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
206 | */ |
965
dfdfedbe2c86
remove single-member structs
Mike Becker <universe@uap-core.de>
parents:
954
diff
changeset
|
207 | typedef enum cx_json_literal CxJsonLiteral; |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
208 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
209 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
210 | * Type alias for a key/value pair in a JSON object. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
211 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
212 | typedef struct cx_json_obj_value_s CxJsonObjValue; |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
213 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
214 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
215 | * JSON array structure. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
216 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
217 | struct cx_json_array_s { |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
218 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
219 | * The array data. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
220 | */ |
967
a58f602ed2fe
simplify parsing of array and object elements
Mike Becker <universe@uap-core.de>
parents:
966
diff
changeset
|
221 | CX_ARRAY_DECLARE(CxJsonValue*, array); |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
222 | }; |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
223 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
224 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
225 | * JSON object structure. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
226 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
227 | struct cx_json_object_s { |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
228 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
229 | * The key/value entries. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
230 | */ |
967
a58f602ed2fe
simplify parsing of array and object elements
Mike Becker <universe@uap-core.de>
parents:
966
diff
changeset
|
231 | CX_ARRAY_DECLARE(CxJsonObjValue, values); |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
232 | }; |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
233 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
234 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
235 | * Structure for a key/value entry in a JSON object. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
236 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
237 | struct cx_json_obj_value_s { |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
238 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
239 | * The key a.k.a. name of the value. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
240 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
241 | char *name; |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
242 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
243 | * The value. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
244 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
245 | CxJsonValue *value; |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
246 | }; |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
247 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
248 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
249 | * Structure for a JSON value. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
250 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
251 | struct cx_json_value_s { |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
252 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
253 | * The allocator with which the value was allocated. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
254 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
255 | * Required for recursively deallocating memory of objects and arrays. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
256 | */ |
996
333155f234c4
add support for allocators to the json parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
988
diff
changeset
|
257 | const CxAllocator *allocator; |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
258 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
259 | * The type of this value. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
260 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
261 | * Specifies how the \c value union shall be resolved. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
262 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
263 | CxJsonValueType type; |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
264 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
265 | * The value data. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
266 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
267 | union { |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
268 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
269 | * The array data if type is #CX_JSON_ARRAY. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
270 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
271 | CxJsonArray array; |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
272 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
273 | * The object data if type is #CX_JSON_OBJECT. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
274 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
275 | CxJsonObject object; |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
276 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
277 | * The string data if type is #CX_JSON_STRING. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
278 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
279 | CxJsonString string; |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
280 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
281 | * The integer if type is #CX_JSON_INTEGER. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
282 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
283 | CxJsonInteger integer; |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
284 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
285 | * The number if type is #CX_JSON_NUMBER. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
286 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
287 | CxJsonNumber number; |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
288 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
289 | * The literal type if type is #CX_JSON_LITERAL. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
290 | */ |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
291 | CxJsonLiteral literal; |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
292 | } value; |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
293 | }; |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
294 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
295 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
296 | * Structure for a parsed token. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
297 | */ |
1000
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
298 | struct cx_json_token_s { |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
299 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
300 | * The token type. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
301 | */ |
1000
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
302 | CxJsonTokenType tokentype; |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
303 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
304 | * True, iff the \c content must be passed to cx_strfree(). |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
305 | */ |
1002
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
306 | bool allocated; |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
307 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
308 | * The token text, if any. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
309 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
310 | * This is not necessarily set when the token type already |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
311 | * uniquely identifies the content. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
312 | */ |
1002
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
313 | cxmutstr content; |
1000
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
314 | }; |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
315 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
316 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
317 | * The JSON parser interface. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
318 | */ |
1000
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
319 | struct cx_json_s { |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
320 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
321 | * The allocator used for produced JSON values. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
322 | */ |
1000
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
323 | const CxAllocator *allocator; |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
324 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
325 | * The input buffer. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
326 | */ |
1007
81b2986d2b04
fix that cxBufferSeek() cannot move pos past the end - fixes #523
Mike Becker <universe@uap-core.de>
parents:
1002
diff
changeset
|
327 | CxBuffer buffer; |
1000
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
328 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
329 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
330 | * Used internally. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
331 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
332 | * Remembers the prefix of the last uncompleted token. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
333 | */ |
1000
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
334 | CxJsonToken uncompleted; |
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
335 | |
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
336 | /** |
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
337 | * A pointer to an intermediate state of the currently parsed value. |
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
338 | * |
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
339 | * Never access this value manually. |
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
340 | */ |
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
341 | CxJsonValue *parsed; |
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
342 | |
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
343 | /** |
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
344 | * State stack. |
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
345 | */ |
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
346 | CX_ARRAY_DECLARE_SIZED(int, states, unsigned); |
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
347 | |
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
348 | /** |
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
349 | * Value buffer stack. |
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
350 | */ |
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
351 | CX_ARRAY_DECLARE_SIZED(CxJsonValue*, vbuf, unsigned); |
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
352 | |
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
353 | /** |
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
354 | * Internally reserved memory for the state stack. |
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
355 | */ |
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
356 | int states_internal[8]; |
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
357 | |
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
358 | /** |
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
359 | * Internally reserved memory for the value buffer stack. |
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
360 | */ |
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
361 | CxJsonValue* vbuf_internal[8]; |
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
362 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
363 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
364 | * Used internally. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
365 | */ |
1000
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
366 | bool tokenizer_escape; // TODO: check if it can be replaced with look-behind |
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
367 | }; |
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
368 | |
1002
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
369 | /** |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
370 | * Status codes for the json interface. |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
371 | */ |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
372 | enum cx_json_status { |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
373 | /** |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
374 | * Everything is fine. |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
375 | */ |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
376 | CX_JSON_NO_ERROR, |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
377 | /** |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
378 | * The input buffer does not contain more data. |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
379 | */ |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
380 | CX_JSON_NO_DATA, |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
381 | /** |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
382 | * The input ends unexpectedly. |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
383 | * |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
384 | * Refill the buffer with cxJsonFill() to complete the json data. |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
385 | */ |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
386 | CX_JSON_INCOMPLETE_DATA, |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
387 | /** |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
388 | * Not used as a status and never returned by any function. |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
389 | * |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
390 | * You can use this enumerator to check for all "good" status results |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
391 | * by checking if the status is less than \c CX_JSON_OK. |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
392 | * |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
393 | * A "good" status means, that you can refill data and continue parsing. |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
394 | */ |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
395 | CX_JSON_OK, |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
396 | /** |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
397 | * Allocating memory for the internal buffer failed. |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
398 | */ |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
399 | CX_JSON_BUFFER_ALLOC_FAILED, |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
400 | /** |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
401 | * Allocating memory for a json value failed. |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
402 | */ |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
403 | CX_JSON_VALUE_ALLOC_FAILED, |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
404 | /** |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
405 | * A number value is incorrectly formatted. |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
406 | */ |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
407 | CX_JSON_FORMAT_ERROR_NUMBER, |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
408 | /** |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
409 | * The tokenizer found something unexpected. |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
410 | */ |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
411 | CX_JSON_FORMAT_ERROR_UNEXPECTED_TOKEN |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
412 | }; |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
413 | |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
414 | /** |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
415 | * Typedef for the json status enum. |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
416 | */ |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
417 | typedef enum cx_json_status CxJsonStatus; |
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
418 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
419 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
420 | * Initializes the json interface. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
421 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
422 | * @param json the json interface |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
423 | * @param allocator the allocator that shall be used for the produced values |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
424 | * @see cxJsonDestroy() |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
425 | */ |
1000
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
426 | cx_attr_nonnull_arg(1) |
1aecddf7e209
simplify how the json parser works
Mike Becker <universe@uap-core.de>
parents:
996
diff
changeset
|
427 | void cxJsonInit(CxJson *json, const CxAllocator *allocator); |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
428 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
429 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
430 | * Destroys the json interface. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
431 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
432 | * @param json the json interface |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
433 | * @see cxJsonInit() |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
434 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
974
diff
changeset
|
435 | cx_attr_nonnull |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
436 | void cxJsonDestroy(CxJson *json); |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
437 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
438 | /** |
1013
add8358fc3c3
add cxJsonReset() and cxPropertiesReset()
Mike Becker <universe@uap-core.de>
parents:
1012
diff
changeset
|
439 | * Destroys and re-initializes the json interface. |
add8358fc3c3
add cxJsonReset() and cxPropertiesReset()
Mike Becker <universe@uap-core.de>
parents:
1012
diff
changeset
|
440 | * |
add8358fc3c3
add cxJsonReset() and cxPropertiesReset()
Mike Becker <universe@uap-core.de>
parents:
1012
diff
changeset
|
441 | * You might want to use this, to reset the parser after |
add8358fc3c3
add cxJsonReset() and cxPropertiesReset()
Mike Becker <universe@uap-core.de>
parents:
1012
diff
changeset
|
442 | * encountering a syntax error. |
add8358fc3c3
add cxJsonReset() and cxPropertiesReset()
Mike Becker <universe@uap-core.de>
parents:
1012
diff
changeset
|
443 | * |
add8358fc3c3
add cxJsonReset() and cxPropertiesReset()
Mike Becker <universe@uap-core.de>
parents:
1012
diff
changeset
|
444 | * @param json the json interface |
add8358fc3c3
add cxJsonReset() and cxPropertiesReset()
Mike Becker <universe@uap-core.de>
parents:
1012
diff
changeset
|
445 | */ |
add8358fc3c3
add cxJsonReset() and cxPropertiesReset()
Mike Becker <universe@uap-core.de>
parents:
1012
diff
changeset
|
446 | cx_attr_nonnull |
add8358fc3c3
add cxJsonReset() and cxPropertiesReset()
Mike Becker <universe@uap-core.de>
parents:
1012
diff
changeset
|
447 | static inline void cxJsonReset(CxJson *json) { |
add8358fc3c3
add cxJsonReset() and cxPropertiesReset()
Mike Becker <universe@uap-core.de>
parents:
1012
diff
changeset
|
448 | const CxAllocator *allocator = json->allocator; |
add8358fc3c3
add cxJsonReset() and cxPropertiesReset()
Mike Becker <universe@uap-core.de>
parents:
1012
diff
changeset
|
449 | cxJsonDestroy(json); |
add8358fc3c3
add cxJsonReset() and cxPropertiesReset()
Mike Becker <universe@uap-core.de>
parents:
1012
diff
changeset
|
450 | cxJsonInit(json, allocator); |
add8358fc3c3
add cxJsonReset() and cxPropertiesReset()
Mike Becker <universe@uap-core.de>
parents:
1012
diff
changeset
|
451 | } |
add8358fc3c3
add cxJsonReset() and cxPropertiesReset()
Mike Becker <universe@uap-core.de>
parents:
1012
diff
changeset
|
452 | |
add8358fc3c3
add cxJsonReset() and cxPropertiesReset()
Mike Becker <universe@uap-core.de>
parents:
1012
diff
changeset
|
453 | /** |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
454 | * Adds more data to the input buffer. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
455 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
456 | * The data will be copied. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
457 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
458 | * @param json the json interface |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
459 | * @param buf the source buffer |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
460 | * @param len the length of the source buffer |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
461 | * @return zero on success, non-zero on internal allocation error |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
462 | * @see cxJsonFill() |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
463 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
974
diff
changeset
|
464 | cx_attr_nonnull |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
974
diff
changeset
|
465 | cx_attr_access_r(2, 3) |
973
05910a8994f7
add UCX string support to cxJsonFill()
Mike Becker <universe@uap-core.de>
parents:
967
diff
changeset
|
466 | int cxJsonFilln(CxJson *json, const char *buf, size_t len); |
05910a8994f7
add UCX string support to cxJsonFill()
Mike Becker <universe@uap-core.de>
parents:
967
diff
changeset
|
467 | |
988
15b3ca7ee33f
make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
468 | #ifdef __cplusplus |
15b3ca7ee33f
make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
469 | } // extern "C" |
15b3ca7ee33f
make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
470 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
471 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
472 | * Adds more data to the input buffer. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
473 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
474 | * The data will be copied. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
475 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
476 | * @param json the json interface |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
477 | * @param str the string to add to the buffer |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
478 | * @return zero on success, non-zero on internal allocation error |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
479 | * @see cxJsonFilln() |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
480 | */ |
988
15b3ca7ee33f
make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
481 | cx_attr_nonnull |
15b3ca7ee33f
make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
482 | static inline int cxJsonFill( |
15b3ca7ee33f
make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
483 | CxJson *json, |
15b3ca7ee33f
make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
484 | cxstring str |
15b3ca7ee33f
make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
485 | ) { |
15b3ca7ee33f
make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
486 | return cxJsonFilln(json, str.ptr, str.length); |
15b3ca7ee33f
make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
487 | } |
15b3ca7ee33f
make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
488 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
489 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
490 | * Adds more data to the input buffer. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
491 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
492 | * The data will be copied. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
493 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
494 | * @param json the json interface |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
495 | * @param str the string to add to the buffer |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
496 | * @return zero on success, non-zero on internal allocation error |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
497 | * @see cxJsonFilln() |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
498 | */ |
988
15b3ca7ee33f
make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
499 | cx_attr_nonnull |
15b3ca7ee33f
make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
500 | static inline int cxJsonFill( |
15b3ca7ee33f
make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
501 | CxJson *json, |
15b3ca7ee33f
make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
502 | cxmutstr str |
15b3ca7ee33f
make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
503 | ) { |
15b3ca7ee33f
make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
504 | return cxJsonFilln(json, str.ptr, str.length); |
15b3ca7ee33f
make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
505 | } |
15b3ca7ee33f
make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
506 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
507 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
508 | * Adds more data to the input buffer. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
509 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
510 | * The data will be copied. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
511 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
512 | * @param json the json interface |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
513 | * @param str the string to add to the buffer |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
514 | * @return zero on success, non-zero on internal allocation error |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
515 | * @see cxJsonFilln() |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
516 | */ |
988
15b3ca7ee33f
make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
517 | cx_attr_nonnull |
15b3ca7ee33f
make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
518 | cx_attr_cstr_arg(2) |
15b3ca7ee33f
make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
519 | static inline int cxJsonFill( |
15b3ca7ee33f
make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
520 | CxJson *json, |
15b3ca7ee33f
make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
521 | const char *str |
15b3ca7ee33f
make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
522 | ) { |
15b3ca7ee33f
make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
523 | return cxJsonFilln(json, str, strlen(str)); |
15b3ca7ee33f
make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
524 | } |
15b3ca7ee33f
make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
525 | |
15b3ca7ee33f
make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
526 | extern "C" { |
15b3ca7ee33f
make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
527 | #else // __cplusplus |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
528 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
529 | * Adds more data to the input buffer. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
530 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
531 | * The data will be copied. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
532 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
533 | * @param json the json interface |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
534 | * @param str the string to add to the buffer |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
535 | * @return zero on success, non-zero on internal allocation error |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
536 | * @see cxJsonFilln() |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
537 | */ |
974
ed44741d8ab5
fix copy-pasted parameter name
Mike Becker <universe@uap-core.de>
parents:
973
diff
changeset
|
538 | #define cxJsonFill(json, str) _Generic((str), \ |
973
05910a8994f7
add UCX string support to cxJsonFill()
Mike Becker <universe@uap-core.de>
parents:
967
diff
changeset
|
539 | cxstring: cx_json_fill_cxstr, \ |
05910a8994f7
add UCX string support to cxJsonFill()
Mike Becker <universe@uap-core.de>
parents:
967
diff
changeset
|
540 | cxmutstr: cx_json_fill_mutstr, \ |
05910a8994f7
add UCX string support to cxJsonFill()
Mike Becker <universe@uap-core.de>
parents:
967
diff
changeset
|
541 | char*: cx_json_fill_str, \ |
05910a8994f7
add UCX string support to cxJsonFill()
Mike Becker <universe@uap-core.de>
parents:
967
diff
changeset
|
542 | const char*: cx_json_fill_str) \ |
974
ed44741d8ab5
fix copy-pasted parameter name
Mike Becker <universe@uap-core.de>
parents:
973
diff
changeset
|
543 | (json, str) |
973
05910a8994f7
add UCX string support to cxJsonFill()
Mike Becker <universe@uap-core.de>
parents:
967
diff
changeset
|
544 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
545 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
546 | * Adds more data to the input buffer. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
547 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
548 | * Internal function - please use the #cxJsonFill() macro. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
549 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
550 | * @param json the json interface |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
551 | * @param str the string to add to the buffer |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
552 | * @return zero on success, non-zero on internal allocation error |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
553 | * @see cxJsonFill() |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
554 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
974
diff
changeset
|
555 | cx_attr_nonnull |
973
05910a8994f7
add UCX string support to cxJsonFill()
Mike Becker <universe@uap-core.de>
parents:
967
diff
changeset
|
556 | static inline int cx_json_fill_cxstr( |
05910a8994f7
add UCX string support to cxJsonFill()
Mike Becker <universe@uap-core.de>
parents:
967
diff
changeset
|
557 | CxJson *json, |
05910a8994f7
add UCX string support to cxJsonFill()
Mike Becker <universe@uap-core.de>
parents:
967
diff
changeset
|
558 | cxstring str |
05910a8994f7
add UCX string support to cxJsonFill()
Mike Becker <universe@uap-core.de>
parents:
967
diff
changeset
|
559 | ) { |
05910a8994f7
add UCX string support to cxJsonFill()
Mike Becker <universe@uap-core.de>
parents:
967
diff
changeset
|
560 | return cxJsonFilln(json, str.ptr, str.length); |
05910a8994f7
add UCX string support to cxJsonFill()
Mike Becker <universe@uap-core.de>
parents:
967
diff
changeset
|
561 | } |
05910a8994f7
add UCX string support to cxJsonFill()
Mike Becker <universe@uap-core.de>
parents:
967
diff
changeset
|
562 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
563 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
564 | * Adds more data to the input buffer. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
565 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
566 | * Internal function - please use the #cxJsonFill() macro. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
567 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
568 | * @param json the json interface |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
569 | * @param str the string to add to the buffer |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
570 | * @return zero on success, non-zero on internal allocation error |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
571 | * @see cxJsonFill() |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
572 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
974
diff
changeset
|
573 | cx_attr_nonnull |
973
05910a8994f7
add UCX string support to cxJsonFill()
Mike Becker <universe@uap-core.de>
parents:
967
diff
changeset
|
574 | static inline int cx_json_fill_mutstr( |
05910a8994f7
add UCX string support to cxJsonFill()
Mike Becker <universe@uap-core.de>
parents:
967
diff
changeset
|
575 | CxJson *json, |
05910a8994f7
add UCX string support to cxJsonFill()
Mike Becker <universe@uap-core.de>
parents:
967
diff
changeset
|
576 | cxmutstr str |
05910a8994f7
add UCX string support to cxJsonFill()
Mike Becker <universe@uap-core.de>
parents:
967
diff
changeset
|
577 | ) { |
05910a8994f7
add UCX string support to cxJsonFill()
Mike Becker <universe@uap-core.de>
parents:
967
diff
changeset
|
578 | return cxJsonFilln(json, str.ptr, str.length); |
05910a8994f7
add UCX string support to cxJsonFill()
Mike Becker <universe@uap-core.de>
parents:
967
diff
changeset
|
579 | } |
05910a8994f7
add UCX string support to cxJsonFill()
Mike Becker <universe@uap-core.de>
parents:
967
diff
changeset
|
580 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
581 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
582 | * Adds more data to the input buffer. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
583 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
584 | * Internal function - please use the #cxJsonFill() macro. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
585 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
586 | * @param json the json interface |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
587 | * @param str the string to add to the buffer |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
588 | * @return zero on success, non-zero on internal allocation error |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
589 | * @see cxJsonFill() |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
590 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
974
diff
changeset
|
591 | cx_attr_nonnull |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
974
diff
changeset
|
592 | cx_attr_cstr_arg(2) |
973
05910a8994f7
add UCX string support to cxJsonFill()
Mike Becker <universe@uap-core.de>
parents:
967
diff
changeset
|
593 | static inline int cx_json_fill_str( |
05910a8994f7
add UCX string support to cxJsonFill()
Mike Becker <universe@uap-core.de>
parents:
967
diff
changeset
|
594 | CxJson *json, |
05910a8994f7
add UCX string support to cxJsonFill()
Mike Becker <universe@uap-core.de>
parents:
967
diff
changeset
|
595 | const char *str |
05910a8994f7
add UCX string support to cxJsonFill()
Mike Becker <universe@uap-core.de>
parents:
967
diff
changeset
|
596 | ) { |
05910a8994f7
add UCX string support to cxJsonFill()
Mike Becker <universe@uap-core.de>
parents:
967
diff
changeset
|
597 | return cxJsonFilln(json, str, strlen(str)); |
05910a8994f7
add UCX string support to cxJsonFill()
Mike Becker <universe@uap-core.de>
parents:
967
diff
changeset
|
598 | } |
988
15b3ca7ee33f
make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
599 | #endif |
973
05910a8994f7
add UCX string support to cxJsonFill()
Mike Becker <universe@uap-core.de>
parents:
967
diff
changeset
|
600 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
601 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
602 | * Recursively deallocates the memory of a JSON value. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
603 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
604 | * \remark The type of each deallocated value will be changed |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
605 | * to #CX_JSON_NOTHING and values of such type will be skipped |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
606 | * by the de-allocation. That means, this function protects |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
607 | * you from double-frees when you are accidentally freeing |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
608 | * a nested value and then the parent value (or vice versa). |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
609 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
610 | * @param value the value |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
611 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
974
diff
changeset
|
612 | void cxJsonValueFree(CxJsonValue *value); |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
613 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
614 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
615 | * Tries to obtain the next JSON value. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
616 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
617 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
618 | * @param json the json interface |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
619 | * @param value a pointer where the next value shall be stored |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
620 | * @return a status code |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
621 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
974
diff
changeset
|
622 | cx_attr_nonnull |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
623 | cx_attr_access_w(2) |
1002
1483c47063a8
add status codes to json parser - relates to #431
Mike Becker <universe@uap-core.de>
parents:
1000
diff
changeset
|
624 | CxJsonStatus cxJsonNext(CxJson *json, CxJsonValue **value); |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
625 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
626 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
627 | * Checks if the specified value is a JSON object. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
628 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
629 | * @param value a pointer to the value |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
630 | * @return true if the value is a JSON object, false otherwise |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
631 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
974
diff
changeset
|
632 | cx_attr_nonnull |
1009 | 633 | static inline bool cxJsonIsObject(const CxJsonValue *value) { |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
634 | return value->type == CX_JSON_OBJECT; |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
635 | } |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
636 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
637 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
638 | * Checks if the specified value is a JSON array. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
639 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
640 | * @param value a pointer to the value |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
641 | * @return true if the value is a JSON array, false otherwise |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
642 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
974
diff
changeset
|
643 | cx_attr_nonnull |
1009 | 644 | static inline bool cxJsonIsArray(const CxJsonValue *value) { |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
645 | return value->type == CX_JSON_ARRAY; |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
646 | } |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
647 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
648 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
649 | * Checks if the specified value is a string. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
650 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
651 | * @param value a pointer to the value |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
652 | * @return true if the value is a string, false otherwise |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
653 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
974
diff
changeset
|
654 | cx_attr_nonnull |
1009 | 655 | static inline bool cxJsonIsString(const CxJsonValue *value) { |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
656 | return value->type == CX_JSON_STRING; |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
657 | } |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
658 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
659 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
660 | * Checks if the specified value is a JSON number. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
661 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
662 | * This function will return true for both floating point and |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
663 | * integer numbers. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
664 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
665 | * @param value a pointer to the value |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
666 | * @return true if the value is a JSON number, false otherwise |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
667 | * @see cxJsonIsInteger() |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
668 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
974
diff
changeset
|
669 | cx_attr_nonnull |
1009 | 670 | static inline bool cxJsonIsNumber(const CxJsonValue *value) { |
966
1aa7ec3e46e7
treat integers and doubles both as JSON numbers
Mike Becker <universe@uap-core.de>
parents:
965
diff
changeset
|
671 | return value->type == CX_JSON_NUMBER || value->type == CX_JSON_INTEGER; |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
672 | } |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
673 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
674 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
675 | * Checks if the specified value is an integer number. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
676 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
677 | * @param value a pointer to the value |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
678 | * @return true if the value is an integer number, false otherwise |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
679 | * @see cxJsonIsNumber() |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
680 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
974
diff
changeset
|
681 | cx_attr_nonnull |
1009 | 682 | static inline bool cxJsonIsInteger(const CxJsonValue *value) { |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
683 | return value->type == CX_JSON_INTEGER; |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
684 | } |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
685 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
686 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
687 | * Checks if the specified value is a JSON literal. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
688 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
689 | * JSON literals are \c true, \c false, and \c null. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
690 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
691 | * @param value a pointer to the value |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
692 | * @return true if the value is a JSON literal, false otherwise |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
693 | * @see cxJsonIsTrue() |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
694 | * @see cxJsonIsFalse() |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
695 | * @see cxJsonIsNull() |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
696 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
974
diff
changeset
|
697 | cx_attr_nonnull |
1009 | 698 | static inline bool cxJsonIsLiteral(const CxJsonValue *value) { |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
699 | return value->type == CX_JSON_LITERAL; |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
700 | } |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
701 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
702 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
703 | * Checks if the specified value is a Boolean literal. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
704 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
705 | * @param value a pointer to the value |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
706 | * @return true if the value is either \c true or \c false, false otherwise |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
707 | * @see cxJsonIsTrue() |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
708 | * @see cxJsonIsFalse() |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
709 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
974
diff
changeset
|
710 | cx_attr_nonnull |
1009 | 711 | static inline bool cxJsonIsBool(const CxJsonValue *value) { |
965
dfdfedbe2c86
remove single-member structs
Mike Becker <universe@uap-core.de>
parents:
954
diff
changeset
|
712 | return cxJsonIsLiteral(value) && value->value.literal != CX_JSON_NULL; |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
713 | } |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
714 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
715 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
716 | * Checks if the specified value is \c true. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
717 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
718 | * \remark Be advised, that this is not the same as |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
719 | * testing \c !cxJsonIsFalse(v). |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
720 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
721 | * @param value a pointer to the value |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
722 | * @return true if the value is \c true, false otherwise |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
723 | * @see cxJsonIsBool() |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
724 | * @see cxJsonIsFalse() |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
725 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
974
diff
changeset
|
726 | cx_attr_nonnull |
1009 | 727 | static inline bool cxJsonIsTrue(const CxJsonValue *value) { |
965
dfdfedbe2c86
remove single-member structs
Mike Becker <universe@uap-core.de>
parents:
954
diff
changeset
|
728 | return cxJsonIsLiteral(value) && value->value.literal == CX_JSON_TRUE; |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
729 | } |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
730 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
731 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
732 | * Checks if the specified value is \c false. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
733 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
734 | * \remark Be advised, that this is not the same as |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
735 | * testing \c !cxJsonIsTrue(v). |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
736 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
737 | * @param value a pointer to the value |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
738 | * @return true if the value is \c false, false otherwise |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
739 | * @see cxJsonIsBool() |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
740 | * @see cxJsonIsTrue() |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
741 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
974
diff
changeset
|
742 | cx_attr_nonnull |
1009 | 743 | static inline bool cxJsonIsFalse(const CxJsonValue *value) { |
965
dfdfedbe2c86
remove single-member structs
Mike Becker <universe@uap-core.de>
parents:
954
diff
changeset
|
744 | return cxJsonIsLiteral(value) && value->value.literal == CX_JSON_FALSE; |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
745 | } |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
746 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
747 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
748 | * Checks if the specified value is \c null. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
749 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
750 | * @param value a pointer to the value |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
751 | * @return true if the value is \c null, false otherwise |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
752 | * @see cxJsonIsLiteral() |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
753 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
974
diff
changeset
|
754 | cx_attr_nonnull |
1009 | 755 | static inline bool cxJsonIsNull(const CxJsonValue *value) { |
965
dfdfedbe2c86
remove single-member structs
Mike Becker <universe@uap-core.de>
parents:
954
diff
changeset
|
756 | return cxJsonIsLiteral(value) && value->value.literal == CX_JSON_NULL; |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
757 | } |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
758 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
759 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
760 | * Obtains a C string from the given JSON value. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
761 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
762 | * If the value is not a string, the behavior is undefined. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
763 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
764 | * @param value the JSON value |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
765 | * @return the value represented as C string |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
766 | * @see cxJsonIsString() |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
767 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
974
diff
changeset
|
768 | cx_attr_nonnull |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
974
diff
changeset
|
769 | cx_attr_returns_nonnull |
1009 | 770 | static inline char *cxJsonAsString(const CxJsonValue *value) { |
966
1aa7ec3e46e7
treat integers and doubles both as JSON numbers
Mike Becker <universe@uap-core.de>
parents:
965
diff
changeset
|
771 | return value->value.string.ptr; |
1aa7ec3e46e7
treat integers and doubles both as JSON numbers
Mike Becker <universe@uap-core.de>
parents:
965
diff
changeset
|
772 | } |
1aa7ec3e46e7
treat integers and doubles both as JSON numbers
Mike Becker <universe@uap-core.de>
parents:
965
diff
changeset
|
773 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
774 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
775 | * Obtains a UCX string from the given JSON value. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
776 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
777 | * If the value is not a string, the behavior is undefined. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
778 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
779 | * @param value the JSON value |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
780 | * @return the value represented as UCX string |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
781 | * @see cxJsonIsString() |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
782 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
974
diff
changeset
|
783 | cx_attr_nonnull |
1009 | 784 | static inline cxstring cxJsonAsCxString(const CxJsonValue *value) { |
966
1aa7ec3e46e7
treat integers and doubles both as JSON numbers
Mike Becker <universe@uap-core.de>
parents:
965
diff
changeset
|
785 | return cx_strcast(value->value.string); |
1aa7ec3e46e7
treat integers and doubles both as JSON numbers
Mike Becker <universe@uap-core.de>
parents:
965
diff
changeset
|
786 | } |
1aa7ec3e46e7
treat integers and doubles both as JSON numbers
Mike Becker <universe@uap-core.de>
parents:
965
diff
changeset
|
787 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
788 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
789 | * Obtains a mutable UCX string from the given JSON value. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
790 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
791 | * If the value is not a string, the behavior is undefined. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
792 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
793 | * @param value the JSON value |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
794 | * @return the value represented as mutable UCX string |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
795 | * @see cxJsonIsString() |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
796 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
974
diff
changeset
|
797 | cx_attr_nonnull |
1009 | 798 | static inline cxmutstr cxJsonAsCxMutStr(const CxJsonValue *value) { |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
799 | return value->value.string; |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
800 | } |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
801 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
802 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
803 | * Obtains a double-precision floating point value from the given JSON value. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
804 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
805 | * If the value is not a JSON number, the behavior is undefined. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
806 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
807 | * @param value the JSON value |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
808 | * @return the value represented as double |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
809 | * @see cxJsonIsNumber() |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
810 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
974
diff
changeset
|
811 | cx_attr_nonnull |
1009 | 812 | static inline double cxJsonAsDouble(const CxJsonValue *value) { |
966
1aa7ec3e46e7
treat integers and doubles both as JSON numbers
Mike Becker <universe@uap-core.de>
parents:
965
diff
changeset
|
813 | if (value->type == CX_JSON_INTEGER) { |
1aa7ec3e46e7
treat integers and doubles both as JSON numbers
Mike Becker <universe@uap-core.de>
parents:
965
diff
changeset
|
814 | return (double) value->value.integer; |
1aa7ec3e46e7
treat integers and doubles both as JSON numbers
Mike Becker <universe@uap-core.de>
parents:
965
diff
changeset
|
815 | } else { |
1aa7ec3e46e7
treat integers and doubles both as JSON numbers
Mike Becker <universe@uap-core.de>
parents:
965
diff
changeset
|
816 | return value->value.number; |
1aa7ec3e46e7
treat integers and doubles both as JSON numbers
Mike Becker <universe@uap-core.de>
parents:
965
diff
changeset
|
817 | } |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
818 | } |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
819 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
820 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
821 | * Obtains a 64-bit signed integer from the given JSON value. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
822 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
823 | * If the value is not a JSON number, the behavior is undefined. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
824 | * If it is a JSON number, but not an integer, the value will be |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
825 | * converted to an integer, possibly losing precision. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
826 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
827 | * @param value the JSON value |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
828 | * @return the value represented as double |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
829 | * @see cxJsonIsNumber() |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
830 | * @see cxJsonIsInteger() |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
831 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
974
diff
changeset
|
832 | cx_attr_nonnull |
1009 | 833 | static inline int64_t cxJsonAsInteger(const CxJsonValue *value) { |
966
1aa7ec3e46e7
treat integers and doubles both as JSON numbers
Mike Becker <universe@uap-core.de>
parents:
965
diff
changeset
|
834 | if (value->type == CX_JSON_INTEGER) { |
1aa7ec3e46e7
treat integers and doubles both as JSON numbers
Mike Becker <universe@uap-core.de>
parents:
965
diff
changeset
|
835 | return value->value.integer; |
1aa7ec3e46e7
treat integers and doubles both as JSON numbers
Mike Becker <universe@uap-core.de>
parents:
965
diff
changeset
|
836 | } else { |
1aa7ec3e46e7
treat integers and doubles both as JSON numbers
Mike Becker <universe@uap-core.de>
parents:
965
diff
changeset
|
837 | return (int64_t) value->value.number; |
1aa7ec3e46e7
treat integers and doubles both as JSON numbers
Mike Becker <universe@uap-core.de>
parents:
965
diff
changeset
|
838 | } |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
839 | } |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
840 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
841 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
842 | * Obtains a Boolean value from the given JSON value. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
843 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
844 | * If the value is not a JSON literal, the behavior is undefined. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
845 | * The \c null literal is interpreted as \c false. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
846 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
847 | * @param value the JSON value |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
848 | * @return the value represented as double |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
849 | * @see cxJsonIsLiteral() |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
850 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
974
diff
changeset
|
851 | cx_attr_nonnull |
1009 | 852 | static inline bool cxJsonAsBool(const CxJsonValue *value) { |
965
dfdfedbe2c86
remove single-member structs
Mike Becker <universe@uap-core.de>
parents:
954
diff
changeset
|
853 | return value->value.literal == CX_JSON_TRUE; |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
854 | } |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
855 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
856 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
857 | * Returns the size of a JSON array. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
858 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
859 | * If the value is not a JSON array, the behavior is undefined. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
860 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
861 | * @param value the JSON value |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
862 | * @return the size of the array |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
863 | * @see cxJsonIsArray() |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
864 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
974
diff
changeset
|
865 | cx_attr_nonnull |
1009 | 866 | static inline size_t cxJsonArrSize(const CxJsonValue *value) { |
967
a58f602ed2fe
simplify parsing of array and object elements
Mike Becker <universe@uap-core.de>
parents:
966
diff
changeset
|
867 | return value->value.array.array_size; |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
868 | } |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
869 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
870 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
871 | * Returns an element from a JSON array. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
872 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
873 | * If the value is not a JSON array, the behavior is undefined. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
874 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
875 | * This function guarantees to return a value. If the index is |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
876 | * out of bounds, the returned value will be of type |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
877 | * #CX_JSON_NOTHING, but never \c NULL. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
878 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
879 | * @param value the JSON value |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
880 | * @param index the index in the array |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
881 | * @return the value at the specified index |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
882 | * @see cxJsonIsArray() |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
883 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
974
diff
changeset
|
884 | cx_attr_nonnull |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
974
diff
changeset
|
885 | cx_attr_returns_nonnull |
1009 | 886 | CxJsonValue *cxJsonArrGet(const CxJsonValue *value, size_t index); |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
887 | |
1012
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
888 | /** |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
889 | * Returns a value corresponding to a key in a JSON object. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
890 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
891 | * If the value is not a JSON object, the behavior is undefined. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
892 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
893 | * This function guarantees to return a JSON value. If the |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
894 | * object does not contain \p name, the returned JSON value |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
895 | * will be of type #CX_JSON_NOTHING, but never \c NULL. |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
896 | * |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
897 | * @param value the JSON object |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
898 | * @param name the key to look up |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
899 | * @return the value corresponding to the key |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
900 | * @see cxJsonIsObject() |
21884374edbb
add documentation - resolves #431
Mike Becker <universe@uap-core.de>
parents:
1009
diff
changeset
|
901 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
974
diff
changeset
|
902 | cx_attr_nonnull |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
974
diff
changeset
|
903 | cx_attr_returns_nonnull |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
974
diff
changeset
|
904 | cx_attr_cstr_arg(2) |
1009 | 905 | CxJsonValue *cxJsonObjGet(const CxJsonValue *value, const char* name); |
937
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
906 | |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
907 | #ifdef __cplusplus |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
908 | } |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
909 | #endif |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
910 | |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
911 | #endif /* UCX_JSON_H */ |
10123f4d5618
add first draft of json implementation - relates to #431
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
912 |