@@ -22,36 +22,177 @@ class document {
22
22
simdjson_really_inline document (document &&other) noexcept = default;
23
23
simdjson_really_inline document &operator =(document &&other) noexcept = default ;
24
24
25
+ /* *
26
+ * Create a new invalid document.
27
+ *
28
+ * Exists so you can declare a variable and later assign to it before use.
29
+ */
25
30
simdjson_really_inline document () noexcept = default;
26
31
simdjson_really_inline document (const document &other) = delete;
27
32
simdjson_really_inline document &operator =(const document &other) = delete ;
33
+ /* *
34
+ * Finishes logging (if logging is enabled).
35
+ */
28
36
simdjson_really_inline ~document () noexcept ;
29
37
38
+ /* *
39
+ * Cast this JSON value to an array.
40
+ *
41
+ * @returns An object that can be used to iterate the array.
42
+ * @returns INCORRECT_TYPE If the JSON value is not an array.
43
+ */
30
44
simdjson_really_inline simdjson_result<array> get_array () & noexcept ;
45
+ /* *
46
+ * Cast this JSON value to an object.
47
+ *
48
+ * @returns An object that can be used to look up or iterate fields.
49
+ * @returns INCORRECT_TYPE If the JSON value is not an object.
50
+ */
31
51
simdjson_really_inline simdjson_result<object> get_object () & noexcept ;
52
+ /* *
53
+ * Cast this JSON value to an unsigned integer.
54
+ *
55
+ * @returns A signed 64-bit integer.
56
+ * @returns INCORRECT_TYPE If the JSON value is not a 64-bit unsigned integer.
57
+ */
32
58
simdjson_really_inline simdjson_result<uint64_t > get_uint64 () noexcept ;
59
+ /* *
60
+ * Cast this JSON value to a signed integer.
61
+ *
62
+ * @returns A signed 64-bit integer.
63
+ * @returns INCORRECT_TYPE If the JSON value is not a 64-bit integer.
64
+ */
33
65
simdjson_really_inline simdjson_result<int64_t > get_int64 () noexcept ;
66
+ /* *
67
+ * Cast this JSON value to a double.
68
+ *
69
+ * @returns A double.
70
+ * @returns INCORRECT_TYPE If the JSON value is not a valid floating-point number.
71
+ */
34
72
simdjson_really_inline simdjson_result<double > get_double () noexcept ;
73
+ /* *
74
+ * Cast this JSON value to a string.
75
+ *
76
+ * The string is guaranteed to be valid UTF-8.
77
+ *
78
+ * Equivalent to get<std::string_view>().
79
+ *
80
+ * @returns An UTF-8 string. The string is stored in the parser and will be invalidated the next
81
+ * time it parses a document or when it is destroyed.
82
+ * @returns INCORRECT_TYPE if the JSON value is not a string.
83
+ */
35
84
simdjson_really_inline simdjson_result<std::string_view> get_string () & noexcept ;
85
+ /* *
86
+ * Cast this JSON value to a raw_json_string.
87
+ *
88
+ * The string is guaranteed to be valid UTF-8, and may have escapes in it (e.g. \\ or \n).
89
+ *
90
+ * @returns A pointer to the raw JSON for the given string.
91
+ * @returns INCORRECT_TYPE if the JSON value is not a string.
92
+ */
36
93
simdjson_really_inline simdjson_result<raw_json_string> get_raw_json_string () & noexcept ;
94
+ /* *
95
+ * Cast this JSON value to a bool.
96
+ *
97
+ * @returns A bool value.
98
+ * @returns INCORRECT_TYPE if the JSON value is not true or false.
99
+ */
37
100
simdjson_really_inline simdjson_result<bool > get_bool () noexcept ;
101
+ /* *
102
+ * Checks if this JSON value is null.
103
+ *
104
+ * @returns Whether the value is null.
105
+ */
38
106
simdjson_really_inline bool is_null () noexcept ;
39
107
40
108
#if SIMDJSON_EXCEPTIONS
109
+ /* *
110
+ * Cast this JSON value to an array.
111
+ *
112
+ * @returns An object that can be used to iterate the array.
113
+ * @exception simdjson_error(INCORRECT_TYPE) If the JSON value is not an array.
114
+ */
41
115
simdjson_really_inline operator array () & noexcept (false );
116
+ /* *
117
+ * Cast this JSON value to an object.
118
+ *
119
+ * @returns An object that can be used to look up or iterate fields.
120
+ * @exception simdjson_error(INCORRECT_TYPE) If the JSON value is not an object.
121
+ */
42
122
simdjson_really_inline operator object () & noexcept (false );
123
+ /* *
124
+ * Cast this JSON value to an unsigned integer.
125
+ *
126
+ * @returns A signed 64-bit integer.
127
+ * @exception simdjson_error(INCORRECT_TYPE) If the JSON value is not a 64-bit unsigned integer.
128
+ */
43
129
simdjson_really_inline operator uint64_t () noexcept (false );
130
+ /* *
131
+ * Cast this JSON value to a signed integer.
132
+ *
133
+ * @returns A signed 64-bit integer.
134
+ * @exception simdjson_error(INCORRECT_TYPE) If the JSON value is not a 64-bit integer.
135
+ */
44
136
simdjson_really_inline operator int64_t () noexcept (false );
137
+ /* *
138
+ * Cast this JSON value to a double.
139
+ *
140
+ * @returns A double.
141
+ * @exception simdjson_error(INCORRECT_TYPE) If the JSON value is not a valid floating-point number.
142
+ */
45
143
simdjson_really_inline operator double () noexcept (false );
144
+ /* *
145
+ * Cast this JSON value to a string.
146
+ *
147
+ * The string is guaranteed to be valid UTF-8.
148
+ *
149
+ * Equivalent to get<std::string_view>().
150
+ *
151
+ * @returns An UTF-8 string. The string is stored in the parser and will be invalidated the next
152
+ * time it parses a document or when it is destroyed.
153
+ * @exception simdjson_error(INCORRECT_TYPE) if the JSON value is not a string.
154
+ */
46
155
simdjson_really_inline operator std::string_view () & noexcept (false );
156
+ /* *
157
+ * Cast this JSON value to a raw_json_string.
158
+ *
159
+ * The string is guaranteed to be valid UTF-8, and may have escapes in it (e.g. \\ or \n).
160
+ *
161
+ * @returns A pointer to the raw JSON for the given string.
162
+ * @exception simdjson_error(INCORRECT_TYPE) if the JSON value is not a string.
163
+ */
47
164
simdjson_really_inline operator raw_json_string () & noexcept (false );
165
+ /* *
166
+ * Cast this JSON value to a bool.
167
+ *
168
+ * @returns A bool value.
169
+ * @exception simdjson_error(INCORRECT_TYPE) if the JSON value is not true or false.
170
+ */
48
171
simdjson_really_inline operator bool () noexcept (false );
49
172
#endif
50
173
51
174
// We don't have an array_iterator that can point at an owned json_iterator
52
175
// simdjson_really_inline simdjson_result<array::iterator> begin() & noexcept;
53
176
// simdjson_really_inline simdjson_result<array::iterator> end() & noexcept;
177
+ /* *
178
+ * Look up a field by name on an object.
179
+ *
180
+ * This method may only be called once on a given value. If you want to look up multiple fields,
181
+ * you must first get the object using value.get_object() or object(value).
182
+ *
183
+ * @param key The key to look up.
184
+ * @returns INCORRECT_TYPE If the JSON value is not an array.
185
+ */
54
186
simdjson_really_inline simdjson_result<value> operator [](std::string_view key) & noexcept ;
187
+ /* *
188
+ * Look up a field by name on an object.
189
+ *
190
+ * This method may only be called once on a given value. If you want to look up multiple fields,
191
+ * you must first get the object using value.get_object() or object(value).
192
+ *
193
+ * @param key The key to look up.
194
+ * @returns INCORRECT_TYPE If the JSON value is not an array.
195
+ */
55
196
simdjson_really_inline simdjson_result<value> operator [](const char *key) & noexcept ;
56
197
57
198
protected:
0 commit comments