| 1 | namespace simdjson { |
| 2 | namespace SIMDJSON_IMPLEMENTATION { |
| 3 | namespace ondemand { |
| 4 | |
| 5 | simdjson_inline document::document(ondemand::json_iterator &&_iter) noexcept |
| 6 | : iter{std::forward<json_iterator>(t&: _iter)} |
| 7 | { |
| 8 | logger::log_start_value(iter, type: "document" ); |
| 9 | } |
| 10 | |
| 11 | simdjson_inline document document::start(json_iterator &&iter) noexcept { |
| 12 | return document(std::forward<json_iterator>(t&: iter)); |
| 13 | } |
| 14 | |
| 15 | inline void document::rewind() noexcept { |
| 16 | iter.rewind(); |
| 17 | } |
| 18 | |
| 19 | inline std::string document::to_debug_string() noexcept { |
| 20 | return iter.to_string(); |
| 21 | } |
| 22 | |
| 23 | inline simdjson_result<const char *> document::current_location() noexcept { |
| 24 | return iter.current_location(); |
| 25 | } |
| 26 | |
| 27 | inline int32_t document::current_depth() const noexcept { |
| 28 | return iter.depth(); |
| 29 | } |
| 30 | |
| 31 | inline bool document::is_alive() noexcept { |
| 32 | return iter.is_alive(); |
| 33 | } |
| 34 | simdjson_inline value_iterator document::resume_value_iterator() noexcept { |
| 35 | return value_iterator(&iter, 1, iter.root_position()); |
| 36 | } |
| 37 | simdjson_inline value_iterator document::get_root_value_iterator() noexcept { |
| 38 | return resume_value_iterator(); |
| 39 | } |
| 40 | simdjson_inline simdjson_result<object> document::start_or_resume_object() noexcept { |
| 41 | if (iter.at_root()) { |
| 42 | return get_object(); |
| 43 | } else { |
| 44 | return object::resume(iter: resume_value_iterator()); |
| 45 | } |
| 46 | } |
| 47 | simdjson_inline simdjson_result<value> document::get_value() noexcept { |
| 48 | // Make sure we start any arrays or objects before returning, so that start_root_<object/array>() |
| 49 | // gets called. |
| 50 | iter.assert_at_document_depth(); |
| 51 | switch (*iter.peek()) { |
| 52 | case '[': |
| 53 | case '{': |
| 54 | return value(get_root_value_iterator()); |
| 55 | default: |
| 56 | // Unfortunately, scalar documents are a special case in simdjson and they cannot |
| 57 | // be safely converted to value instances. |
| 58 | return SCALAR_DOCUMENT_AS_VALUE; |
| 59 | // return value(get_root_value_iterator()); |
| 60 | } |
| 61 | } |
| 62 | simdjson_inline simdjson_result<array> document::get_array() & noexcept { |
| 63 | auto value = get_root_value_iterator(); |
| 64 | return array::start_root(iter&: value); |
| 65 | } |
| 66 | simdjson_inline simdjson_result<object> document::get_object() & noexcept { |
| 67 | auto value = get_root_value_iterator(); |
| 68 | return object::start_root(iter&: value); |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * We decided that calling 'get_double()' on the JSON document '1.233 blabla' should |
| 73 | * give an error, so we check for trailing content. We want to disallow trailing |
| 74 | * content. |
| 75 | * Thus, in several implementations below, we pass a 'true' parameter value to |
| 76 | * a get_root_value_iterator() method: this indicates that we disallow trailing content. |
| 77 | */ |
| 78 | |
| 79 | simdjson_inline simdjson_result<uint64_t> document::get_uint64() noexcept { |
| 80 | return get_root_value_iterator().get_root_uint64(check_trailing: true); |
| 81 | } |
| 82 | simdjson_inline simdjson_result<uint64_t> document::get_uint64_in_string() noexcept { |
| 83 | return get_root_value_iterator().get_root_uint64_in_string(check_trailing: true); |
| 84 | } |
| 85 | simdjson_inline simdjson_result<int64_t> document::get_int64() noexcept { |
| 86 | return get_root_value_iterator().get_root_int64(check_trailing: true); |
| 87 | } |
| 88 | simdjson_inline simdjson_result<int64_t> document::get_int64_in_string() noexcept { |
| 89 | return get_root_value_iterator().get_root_int64_in_string(check_trailing: true); |
| 90 | } |
| 91 | simdjson_inline simdjson_result<double> document::get_double() noexcept { |
| 92 | return get_root_value_iterator().get_root_double(check_trailing: true); |
| 93 | } |
| 94 | simdjson_inline simdjson_result<double> document::get_double_in_string() noexcept { |
| 95 | return get_root_value_iterator().get_root_double_in_string(check_trailing: true); |
| 96 | } |
| 97 | simdjson_inline simdjson_result<std::string_view> document::get_string(bool allow_replacement) noexcept { |
| 98 | return get_root_value_iterator().get_root_string(check_trailing: true, allow_replacement); |
| 99 | } |
| 100 | simdjson_inline simdjson_result<std::string_view> document::get_wobbly_string() noexcept { |
| 101 | return get_root_value_iterator().get_root_wobbly_string(check_trailing: true); |
| 102 | } |
| 103 | simdjson_inline simdjson_result<raw_json_string> document::get_raw_json_string() noexcept { |
| 104 | return get_root_value_iterator().get_root_raw_json_string(check_trailing: true); |
| 105 | } |
| 106 | simdjson_inline simdjson_result<bool> document::get_bool() noexcept { |
| 107 | return get_root_value_iterator().get_root_bool(check_trailing: true); |
| 108 | } |
| 109 | simdjson_inline simdjson_result<bool> document::is_null() noexcept { |
| 110 | return get_root_value_iterator().is_root_null(check_trailing: true); |
| 111 | } |
| 112 | |
| 113 | template<> simdjson_inline simdjson_result<array> document::get() & noexcept { return get_array(); } |
| 114 | template<> simdjson_inline simdjson_result<object> document::get() & noexcept { return get_object(); } |
| 115 | template<> simdjson_inline simdjson_result<raw_json_string> document::get() & noexcept { return get_raw_json_string(); } |
| 116 | template<> simdjson_inline simdjson_result<std::string_view> document::get() & noexcept { return get_string(allow_replacement: false); } |
| 117 | template<> simdjson_inline simdjson_result<double> document::get() & noexcept { return get_double(); } |
| 118 | template<> simdjson_inline simdjson_result<uint64_t> document::get() & noexcept { return get_uint64(); } |
| 119 | template<> simdjson_inline simdjson_result<int64_t> document::get() & noexcept { return get_int64(); } |
| 120 | template<> simdjson_inline simdjson_result<bool> document::get() & noexcept { return get_bool(); } |
| 121 | template<> simdjson_inline simdjson_result<value> document::get() & noexcept { return get_value(); } |
| 122 | |
| 123 | template<> simdjson_inline simdjson_result<raw_json_string> document::get() && noexcept { return get_raw_json_string(); } |
| 124 | template<> simdjson_inline simdjson_result<std::string_view> document::get() && noexcept { return get_string(allow_replacement: false); } |
| 125 | template<> simdjson_inline simdjson_result<double> document::get() && noexcept { return std::forward<document>(t&: *this).get_double(); } |
| 126 | template<> simdjson_inline simdjson_result<uint64_t> document::get() && noexcept { return std::forward<document>(t&: *this).get_uint64(); } |
| 127 | template<> simdjson_inline simdjson_result<int64_t> document::get() && noexcept { return std::forward<document>(t&: *this).get_int64(); } |
| 128 | template<> simdjson_inline simdjson_result<bool> document::get() && noexcept { return std::forward<document>(t&: *this).get_bool(); } |
| 129 | template<> simdjson_inline simdjson_result<value> document::get() && noexcept { return get_value(); } |
| 130 | |
| 131 | template<typename T> simdjson_inline error_code document::get(T &out) & noexcept { |
| 132 | return get<T>().get(out); |
| 133 | } |
| 134 | template<typename T> simdjson_inline error_code document::get(T &out) && noexcept { |
| 135 | return std::forward<document>(t&: *this).get<T>().get(out); |
| 136 | } |
| 137 | |
| 138 | #if SIMDJSON_EXCEPTIONS |
| 139 | simdjson_inline document::operator array() & noexcept(false) { return get_array(); } |
| 140 | simdjson_inline document::operator object() & noexcept(false) { return get_object(); } |
| 141 | simdjson_inline document::operator uint64_t() noexcept(false) { return get_uint64(); } |
| 142 | simdjson_inline document::operator int64_t() noexcept(false) { return get_int64(); } |
| 143 | simdjson_inline document::operator double() noexcept(false) { return get_double(); } |
| 144 | simdjson_inline document::operator std::string_view() noexcept(false) { return get_string(allow_replacement: false); } |
| 145 | simdjson_inline document::operator raw_json_string() noexcept(false) { return get_raw_json_string(); } |
| 146 | simdjson_inline document::operator bool() noexcept(false) { return get_bool(); } |
| 147 | simdjson_inline document::operator value() noexcept(false) { return get_value(); } |
| 148 | |
| 149 | #endif |
| 150 | simdjson_inline simdjson_result<size_t> document::count_elements() & noexcept { |
| 151 | auto a = get_array(); |
| 152 | simdjson_result<size_t> answer = a.count_elements(); |
| 153 | /* If there was an array, we are now left pointing at its first element. */ |
| 154 | if(answer.error() == SUCCESS) { rewind(); } |
| 155 | return answer; |
| 156 | } |
| 157 | simdjson_inline simdjson_result<size_t> document::count_fields() & noexcept { |
| 158 | auto a = get_object(); |
| 159 | simdjson_result<size_t> answer = a.count_fields(); |
| 160 | /* If there was an object, we are now left pointing at its first element. */ |
| 161 | if(answer.error() == SUCCESS) { rewind(); } |
| 162 | return answer; |
| 163 | } |
| 164 | simdjson_inline simdjson_result<value> document::at(size_t index) & noexcept { |
| 165 | auto a = get_array(); |
| 166 | return a.at(index); |
| 167 | } |
| 168 | simdjson_inline simdjson_result<array_iterator> document::begin() & noexcept { |
| 169 | return get_array().begin(); |
| 170 | } |
| 171 | simdjson_inline simdjson_result<array_iterator> document::end() & noexcept { |
| 172 | return {}; |
| 173 | } |
| 174 | |
| 175 | simdjson_inline simdjson_result<value> document::find_field(std::string_view key) & noexcept { |
| 176 | return start_or_resume_object().find_field(key); |
| 177 | } |
| 178 | simdjson_inline simdjson_result<value> document::find_field(const char *key) & noexcept { |
| 179 | return start_or_resume_object().find_field(key); |
| 180 | } |
| 181 | simdjson_inline simdjson_result<value> document::find_field_unordered(std::string_view key) & noexcept { |
| 182 | return start_or_resume_object().find_field_unordered(key); |
| 183 | } |
| 184 | simdjson_inline simdjson_result<value> document::find_field_unordered(const char *key) & noexcept { |
| 185 | return start_or_resume_object().find_field_unordered(key); |
| 186 | } |
| 187 | simdjson_inline simdjson_result<value> document::operator[](std::string_view key) & noexcept { |
| 188 | return start_or_resume_object()[key]; |
| 189 | } |
| 190 | simdjson_inline simdjson_result<value> document::operator[](const char *key) & noexcept { |
| 191 | return start_or_resume_object()[key]; |
| 192 | } |
| 193 | |
| 194 | simdjson_inline error_code document::consume() noexcept { |
| 195 | auto error = iter.skip_child(parent_depth: 0); |
| 196 | if(error) { iter.abandon(); } |
| 197 | return error; |
| 198 | } |
| 199 | |
| 200 | simdjson_inline simdjson_result<std::string_view> document::raw_json() noexcept { |
| 201 | auto _iter = get_root_value_iterator(); |
| 202 | const uint8_t * starting_point{_iter.peek_start()}; |
| 203 | auto error = consume(); |
| 204 | if(error) { return error; } |
| 205 | // After 'consume()', we could be left pointing just beyond the document, but that |
| 206 | // is ok because we are not going to dereference the final pointer position, we just |
| 207 | // use it to compute the length in bytes. |
| 208 | const uint8_t * final_point{iter.unsafe_pointer()}; |
| 209 | return std::string_view(reinterpret_cast<const char*>(starting_point), size_t(final_point - starting_point)); |
| 210 | } |
| 211 | |
| 212 | simdjson_inline simdjson_result<json_type> document::type() noexcept { |
| 213 | return get_root_value_iterator().type(); |
| 214 | } |
| 215 | |
| 216 | simdjson_inline simdjson_result<bool> document::is_scalar() noexcept { |
| 217 | json_type this_type; |
| 218 | auto error = type().get(value&: this_type); |
| 219 | if(error) { return error; } |
| 220 | return ! ((this_type == json_type::array) || (this_type == json_type::object)); |
| 221 | } |
| 222 | |
| 223 | simdjson_inline bool document::is_negative() noexcept { |
| 224 | return get_root_value_iterator().is_root_negative(); |
| 225 | } |
| 226 | |
| 227 | simdjson_inline simdjson_result<bool> document::is_integer() noexcept { |
| 228 | return get_root_value_iterator().is_root_integer(check_trailing: true); |
| 229 | } |
| 230 | |
| 231 | simdjson_inline simdjson_result<number_type> document::get_number_type() noexcept { |
| 232 | return get_root_value_iterator().get_root_number_type(check_trailing: true); |
| 233 | } |
| 234 | |
| 235 | simdjson_inline simdjson_result<number> document::get_number() noexcept { |
| 236 | return get_root_value_iterator().get_root_number(check_trailing: true); |
| 237 | } |
| 238 | |
| 239 | |
| 240 | simdjson_inline simdjson_result<std::string_view> document::raw_json_token() noexcept { |
| 241 | auto _iter = get_root_value_iterator(); |
| 242 | return std::string_view(reinterpret_cast<const char*>(_iter.peek_start()), _iter.peek_start_length()); |
| 243 | } |
| 244 | |
| 245 | simdjson_inline simdjson_result<value> document::at_pointer(std::string_view json_pointer) noexcept { |
| 246 | rewind(); // Rewind the document each time at_pointer is called |
| 247 | if (json_pointer.empty()) { |
| 248 | return this->get_value(); |
| 249 | } |
| 250 | json_type t; |
| 251 | SIMDJSON_TRY(type().get(t)); |
| 252 | switch (t) |
| 253 | { |
| 254 | case json_type::array: |
| 255 | return (*this).get_array().at_pointer(json_pointer); |
| 256 | case json_type::object: |
| 257 | return (*this).get_object().at_pointer(json_pointer); |
| 258 | default: |
| 259 | return INVALID_JSON_POINTER; |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | } // namespace ondemand |
| 264 | } // namespace SIMDJSON_IMPLEMENTATION |
| 265 | } // namespace simdjson |
| 266 | |
| 267 | namespace simdjson { |
| 268 | |
| 269 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::simdjson_result( |
| 270 | SIMDJSON_IMPLEMENTATION::ondemand::document &&value |
| 271 | ) noexcept : |
| 272 | implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::document>( |
| 273 | std::forward<SIMDJSON_IMPLEMENTATION::ondemand::document>(t&: value) |
| 274 | ) |
| 275 | { |
| 276 | } |
| 277 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::simdjson_result( |
| 278 | error_code error |
| 279 | ) noexcept : |
| 280 | implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::document>( |
| 281 | error |
| 282 | ) |
| 283 | { |
| 284 | } |
| 285 | simdjson_inline simdjson_result<size_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::count_elements() & noexcept { |
| 286 | if (error()) { return error(); } |
| 287 | return first.count_elements(); |
| 288 | } |
| 289 | simdjson_inline simdjson_result<size_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::count_fields() & noexcept { |
| 290 | if (error()) { return error(); } |
| 291 | return first.count_fields(); |
| 292 | } |
| 293 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::at(size_t index) & noexcept { |
| 294 | if (error()) { return error(); } |
| 295 | return first.at(index); |
| 296 | } |
| 297 | simdjson_inline error_code simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::rewind() noexcept { |
| 298 | if (error()) { return error(); } |
| 299 | first.rewind(); |
| 300 | return SUCCESS; |
| 301 | } |
| 302 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::begin() & noexcept { |
| 303 | if (error()) { return error(); } |
| 304 | return first.begin(); |
| 305 | } |
| 306 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::end() & noexcept { |
| 307 | return {}; |
| 308 | } |
| 309 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::find_field_unordered(std::string_view key) & noexcept { |
| 310 | if (error()) { return error(); } |
| 311 | return first.find_field_unordered(key); |
| 312 | } |
| 313 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::find_field_unordered(const char *key) & noexcept { |
| 314 | if (error()) { return error(); } |
| 315 | return first.find_field_unordered(key); |
| 316 | } |
| 317 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::operator[](std::string_view key) & noexcept { |
| 318 | if (error()) { return error(); } |
| 319 | return first[key]; |
| 320 | } |
| 321 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::operator[](const char *key) & noexcept { |
| 322 | if (error()) { return error(); } |
| 323 | return first[key]; |
| 324 | } |
| 325 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::find_field(std::string_view key) & noexcept { |
| 326 | if (error()) { return error(); } |
| 327 | return first.find_field(key); |
| 328 | } |
| 329 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::find_field(const char *key) & noexcept { |
| 330 | if (error()) { return error(); } |
| 331 | return first.find_field(key); |
| 332 | } |
| 333 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_array() & noexcept { |
| 334 | if (error()) { return error(); } |
| 335 | return first.get_array(); |
| 336 | } |
| 337 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_object() & noexcept { |
| 338 | if (error()) { return error(); } |
| 339 | return first.get_object(); |
| 340 | } |
| 341 | simdjson_inline simdjson_result<uint64_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_uint64() noexcept { |
| 342 | if (error()) { return error(); } |
| 343 | return first.get_uint64(); |
| 344 | } |
| 345 | simdjson_inline simdjson_result<uint64_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_uint64_in_string() noexcept { |
| 346 | if (error()) { return error(); } |
| 347 | return first.get_uint64_in_string(); |
| 348 | } |
| 349 | simdjson_inline simdjson_result<int64_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_int64() noexcept { |
| 350 | if (error()) { return error(); } |
| 351 | return first.get_int64(); |
| 352 | } |
| 353 | simdjson_inline simdjson_result<int64_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_int64_in_string() noexcept { |
| 354 | if (error()) { return error(); } |
| 355 | return first.get_int64_in_string(); |
| 356 | } |
| 357 | simdjson_inline simdjson_result<double> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_double() noexcept { |
| 358 | if (error()) { return error(); } |
| 359 | return first.get_double(); |
| 360 | } |
| 361 | simdjson_inline simdjson_result<double> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_double_in_string() noexcept { |
| 362 | if (error()) { return error(); } |
| 363 | return first.get_double_in_string(); |
| 364 | } |
| 365 | simdjson_inline simdjson_result<std::string_view> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_string(bool allow_replacement) noexcept { |
| 366 | if (error()) { return error(); } |
| 367 | return first.get_string(allow_replacement); |
| 368 | } |
| 369 | simdjson_inline simdjson_result<std::string_view> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_wobbly_string() noexcept { |
| 370 | if (error()) { return error(); } |
| 371 | return first.get_wobbly_string(); |
| 372 | } |
| 373 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_raw_json_string() noexcept { |
| 374 | if (error()) { return error(); } |
| 375 | return first.get_raw_json_string(); |
| 376 | } |
| 377 | simdjson_inline simdjson_result<bool> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_bool() noexcept { |
| 378 | if (error()) { return error(); } |
| 379 | return first.get_bool(); |
| 380 | } |
| 381 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_value() noexcept { |
| 382 | if (error()) { return error(); } |
| 383 | return first.get_value(); |
| 384 | } |
| 385 | simdjson_inline simdjson_result<bool> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::is_null() noexcept { |
| 386 | if (error()) { return error(); } |
| 387 | return first.is_null(); |
| 388 | } |
| 389 | |
| 390 | template<typename T> |
| 391 | simdjson_inline simdjson_result<T> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get() & noexcept { |
| 392 | if (error()) { return error(); } |
| 393 | return first.get<T>(); |
| 394 | } |
| 395 | template<typename T> |
| 396 | simdjson_inline simdjson_result<T> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get() && noexcept { |
| 397 | if (error()) { return error(); } |
| 398 | return std::forward<SIMDJSON_IMPLEMENTATION::ondemand::document>(t&: first).get<T>(); |
| 399 | } |
| 400 | template<typename T> |
| 401 | simdjson_inline error_code simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get(T &out) & noexcept { |
| 402 | if (error()) { return error(); } |
| 403 | return first.get<T>(out); |
| 404 | } |
| 405 | template<typename T> |
| 406 | simdjson_inline error_code simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get(T &out) && noexcept { |
| 407 | if (error()) { return error(); } |
| 408 | return std::forward<SIMDJSON_IMPLEMENTATION::ondemand::document>(t&: first).get<T>(out); |
| 409 | } |
| 410 | |
| 411 | template<> simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get<SIMDJSON_IMPLEMENTATION::ondemand::document>() & noexcept = delete; |
| 412 | template<> simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get<SIMDJSON_IMPLEMENTATION::ondemand::document>() && noexcept { |
| 413 | if (error()) { return error(); } |
| 414 | return std::forward<SIMDJSON_IMPLEMENTATION::ondemand::document>(t&: first); |
| 415 | } |
| 416 | template<> simdjson_inline error_code simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get<SIMDJSON_IMPLEMENTATION::ondemand::document>(SIMDJSON_IMPLEMENTATION::ondemand::document &out) & noexcept = delete; |
| 417 | template<> simdjson_inline error_code simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get<SIMDJSON_IMPLEMENTATION::ondemand::document>(SIMDJSON_IMPLEMENTATION::ondemand::document &out) && noexcept { |
| 418 | if (error()) { return error(); } |
| 419 | out = std::forward<SIMDJSON_IMPLEMENTATION::ondemand::document>(t&: first); |
| 420 | return SUCCESS; |
| 421 | } |
| 422 | |
| 423 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::json_type> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::type() noexcept { |
| 424 | if (error()) { return error(); } |
| 425 | return first.type(); |
| 426 | } |
| 427 | |
| 428 | simdjson_inline simdjson_result<bool> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::is_scalar() noexcept { |
| 429 | if (error()) { return error(); } |
| 430 | return first.is_scalar(); |
| 431 | } |
| 432 | |
| 433 | |
| 434 | simdjson_inline bool simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::is_negative() noexcept { |
| 435 | if (error()) { return error(); } |
| 436 | return first.is_negative(); |
| 437 | } |
| 438 | |
| 439 | simdjson_inline simdjson_result<bool> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::is_integer() noexcept { |
| 440 | if (error()) { return error(); } |
| 441 | return first.is_integer(); |
| 442 | } |
| 443 | |
| 444 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::number_type> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_number_type() noexcept { |
| 445 | if (error()) { return error(); } |
| 446 | return first.get_number_type(); |
| 447 | } |
| 448 | |
| 449 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::number> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_number() noexcept { |
| 450 | if (error()) { return error(); } |
| 451 | return first.get_number(); |
| 452 | } |
| 453 | |
| 454 | |
| 455 | #if SIMDJSON_EXCEPTIONS |
| 456 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::operator SIMDJSON_IMPLEMENTATION::ondemand::array() & noexcept(false) { |
| 457 | if (error()) { throw simdjson_error(error()); } |
| 458 | return first; |
| 459 | } |
| 460 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::operator SIMDJSON_IMPLEMENTATION::ondemand::object() & noexcept(false) { |
| 461 | if (error()) { throw simdjson_error(error()); } |
| 462 | return first; |
| 463 | } |
| 464 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::operator uint64_t() noexcept(false) { |
| 465 | if (error()) { throw simdjson_error(error()); } |
| 466 | return first; |
| 467 | } |
| 468 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::operator int64_t() noexcept(false) { |
| 469 | if (error()) { throw simdjson_error(error()); } |
| 470 | return first; |
| 471 | } |
| 472 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::operator double() noexcept(false) { |
| 473 | if (error()) { throw simdjson_error(error()); } |
| 474 | return first; |
| 475 | } |
| 476 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::operator std::string_view() noexcept(false) { |
| 477 | if (error()) { throw simdjson_error(error()); } |
| 478 | return first; |
| 479 | } |
| 480 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::operator SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string() noexcept(false) { |
| 481 | if (error()) { throw simdjson_error(error()); } |
| 482 | return first; |
| 483 | } |
| 484 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::operator bool() noexcept(false) { |
| 485 | if (error()) { throw simdjson_error(error()); } |
| 486 | return first; |
| 487 | } |
| 488 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::operator SIMDJSON_IMPLEMENTATION::ondemand::value() noexcept(false) { |
| 489 | if (error()) { throw simdjson_error(error()); } |
| 490 | return first; |
| 491 | } |
| 492 | #endif |
| 493 | |
| 494 | |
| 495 | simdjson_inline simdjson_result<const char *> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::current_location() noexcept { |
| 496 | if (error()) { return error(); } |
| 497 | return first.current_location(); |
| 498 | } |
| 499 | |
| 500 | simdjson_inline int32_t simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::current_depth() const noexcept { |
| 501 | if (error()) { return error(); } |
| 502 | return first.current_depth(); |
| 503 | } |
| 504 | |
| 505 | simdjson_inline simdjson_result<std::string_view> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::raw_json_token() noexcept { |
| 506 | if (error()) { return error(); } |
| 507 | return first.raw_json_token(); |
| 508 | } |
| 509 | |
| 510 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::at_pointer(std::string_view json_pointer) noexcept { |
| 511 | if (error()) { return error(); } |
| 512 | return first.at_pointer(json_pointer); |
| 513 | } |
| 514 | |
| 515 | |
| 516 | } // namespace simdjson |
| 517 | |
| 518 | |
| 519 | namespace simdjson { |
| 520 | namespace SIMDJSON_IMPLEMENTATION { |
| 521 | namespace ondemand { |
| 522 | |
| 523 | simdjson_inline document_reference::document_reference() noexcept : doc{nullptr} {} |
| 524 | simdjson_inline document_reference::document_reference(document &d) noexcept : doc(&d) {} |
| 525 | simdjson_inline void document_reference::rewind() noexcept { doc->rewind(); } |
| 526 | simdjson_inline simdjson_result<array> document_reference::get_array() & noexcept { return doc->get_array(); } |
| 527 | simdjson_inline simdjson_result<object> document_reference::get_object() & noexcept { return doc->get_object(); } |
| 528 | /** |
| 529 | * The document_reference instances are used primarily/solely for streams of JSON |
| 530 | * documents. |
| 531 | * We decided that calling 'get_double()' on the JSON document '1.233 blabla' should |
| 532 | * give an error, so we check for trailing content. |
| 533 | * |
| 534 | * However, for streams of JSON documents, we want to be able to start from |
| 535 | * "321" "321" "321" |
| 536 | * and parse it successfully as a stream of JSON documents, calling get_uint64_in_string() |
| 537 | * successfully each time. |
| 538 | * |
| 539 | * To achieve this result, we pass a 'false' to a get_root_value_iterator() method: |
| 540 | * this indicates that we allow trailing content. |
| 541 | */ |
| 542 | simdjson_inline simdjson_result<uint64_t> document_reference::get_uint64() noexcept { return doc->get_root_value_iterator().get_root_uint64(check_trailing: false); } |
| 543 | simdjson_inline simdjson_result<uint64_t> document_reference::get_uint64_in_string() noexcept { return doc->get_root_value_iterator().get_root_uint64_in_string(check_trailing: false); } |
| 544 | simdjson_inline simdjson_result<int64_t> document_reference::get_int64() noexcept { return doc->get_root_value_iterator().get_root_int64(check_trailing: false); } |
| 545 | simdjson_inline simdjson_result<int64_t> document_reference::get_int64_in_string() noexcept { return doc->get_root_value_iterator().get_root_int64_in_string(check_trailing: false); } |
| 546 | simdjson_inline simdjson_result<double> document_reference::get_double() noexcept { return doc->get_root_value_iterator().get_root_double(check_trailing: false); } |
| 547 | simdjson_inline simdjson_result<double> document_reference::get_double_in_string() noexcept { return doc->get_root_value_iterator().get_root_double(check_trailing: false); } |
| 548 | simdjson_inline simdjson_result<std::string_view> document_reference::get_string(bool allow_replacement) noexcept { return doc->get_root_value_iterator().get_root_string(check_trailing: false, allow_replacement); } |
| 549 | simdjson_inline simdjson_result<std::string_view> document_reference::get_wobbly_string() noexcept { return doc->get_root_value_iterator().get_root_wobbly_string(check_trailing: false); } |
| 550 | simdjson_inline simdjson_result<raw_json_string> document_reference::get_raw_json_string() noexcept { return doc->get_root_value_iterator().get_root_raw_json_string(check_trailing: false); } |
| 551 | simdjson_inline simdjson_result<bool> document_reference::get_bool() noexcept { return doc->get_root_value_iterator().get_root_bool(check_trailing: false); } |
| 552 | simdjson_inline simdjson_result<value> document_reference::get_value() noexcept { return doc->get_value(); } |
| 553 | simdjson_inline simdjson_result<bool> document_reference::is_null() noexcept { return doc->get_root_value_iterator().is_root_null(check_trailing: false); } |
| 554 | |
| 555 | #if SIMDJSON_EXCEPTIONS |
| 556 | simdjson_inline document_reference::operator array() & noexcept(false) { return array(*doc); } |
| 557 | simdjson_inline document_reference::operator object() & noexcept(false) { return object(*doc); } |
| 558 | simdjson_inline document_reference::operator uint64_t() noexcept(false) { return get_uint64(); } |
| 559 | simdjson_inline document_reference::operator int64_t() noexcept(false) { return get_int64(); } |
| 560 | simdjson_inline document_reference::operator double() noexcept(false) { return get_double(); } |
| 561 | simdjson_inline document_reference::operator std::string_view() noexcept(false) { return std::string_view(*doc); } |
| 562 | simdjson_inline document_reference::operator raw_json_string() noexcept(false) { return raw_json_string(*doc); } |
| 563 | simdjson_inline document_reference::operator bool() noexcept(false) { return get_bool(); } |
| 564 | simdjson_inline document_reference::operator value() noexcept(false) { return value(*doc); } |
| 565 | #endif |
| 566 | simdjson_inline simdjson_result<size_t> document_reference::count_elements() & noexcept { return doc->count_elements(); } |
| 567 | simdjson_inline simdjson_result<size_t> document_reference::count_fields() & noexcept { return doc->count_fields(); } |
| 568 | simdjson_inline simdjson_result<value> document_reference::at(size_t index) & noexcept { return doc->at(index); } |
| 569 | simdjson_inline simdjson_result<array_iterator> document_reference::begin() & noexcept { return doc->begin(); } |
| 570 | simdjson_inline simdjson_result<array_iterator> document_reference::end() & noexcept { return doc->end(); } |
| 571 | simdjson_inline simdjson_result<value> document_reference::find_field(std::string_view key) & noexcept { return doc->find_field(key); } |
| 572 | simdjson_inline simdjson_result<value> document_reference::find_field(const char *key) & noexcept { return doc->find_field(key); } |
| 573 | simdjson_inline simdjson_result<value> document_reference::operator[](std::string_view key) & noexcept { return (*doc)[key]; } |
| 574 | simdjson_inline simdjson_result<value> document_reference::operator[](const char *key) & noexcept { return (*doc)[key]; } |
| 575 | simdjson_inline simdjson_result<value> document_reference::find_field_unordered(std::string_view key) & noexcept { return doc->find_field_unordered(key); } |
| 576 | simdjson_inline simdjson_result<value> document_reference::find_field_unordered(const char *key) & noexcept { return doc->find_field_unordered(key); } |
| 577 | simdjson_inline simdjson_result<json_type> document_reference::type() noexcept { return doc->type(); } |
| 578 | simdjson_inline simdjson_result<bool> document_reference::is_scalar() noexcept { return doc->is_scalar(); } |
| 579 | simdjson_inline simdjson_result<const char *> document_reference::current_location() noexcept { return doc->current_location(); } |
| 580 | simdjson_inline int32_t document_reference::current_depth() const noexcept { return doc->current_depth(); } |
| 581 | simdjson_inline bool document_reference::is_negative() noexcept { return doc->is_negative(); } |
| 582 | simdjson_inline simdjson_result<bool> document_reference::is_integer() noexcept { return doc->get_root_value_iterator().is_root_integer(check_trailing: false); } |
| 583 | simdjson_inline simdjson_result<number_type> document_reference::get_number_type() noexcept { return doc->get_root_value_iterator().get_root_number_type(check_trailing: false); } |
| 584 | simdjson_inline simdjson_result<number> document_reference::get_number() noexcept { return doc->get_root_value_iterator().get_root_number(check_trailing: false); } |
| 585 | simdjson_inline simdjson_result<std::string_view> document_reference::raw_json_token() noexcept { return doc->raw_json_token(); } |
| 586 | simdjson_inline simdjson_result<value> document_reference::at_pointer(std::string_view json_pointer) noexcept { return doc->at_pointer(json_pointer); } |
| 587 | simdjson_inline simdjson_result<std::string_view> document_reference::raw_json() noexcept { return doc->raw_json();} |
| 588 | simdjson_inline document_reference::operator document&() const noexcept { return *doc; } |
| 589 | |
| 590 | } // namespace ondemand |
| 591 | } // namespace SIMDJSON_IMPLEMENTATION |
| 592 | } // namespace simdjson |
| 593 | |
| 594 | |
| 595 | |
| 596 | namespace simdjson { |
| 597 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::simdjson_result(SIMDJSON_IMPLEMENTATION::ondemand::document_reference value, error_code error) |
| 598 | noexcept : implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>(std::forward<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>(t&: value), error) {} |
| 599 | |
| 600 | |
| 601 | simdjson_inline simdjson_result<size_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::count_elements() & noexcept { |
| 602 | if (error()) { return error(); } |
| 603 | return first.count_elements(); |
| 604 | } |
| 605 | simdjson_inline simdjson_result<size_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::count_fields() & noexcept { |
| 606 | if (error()) { return error(); } |
| 607 | return first.count_fields(); |
| 608 | } |
| 609 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::at(size_t index) & noexcept { |
| 610 | if (error()) { return error(); } |
| 611 | return first.at(index); |
| 612 | } |
| 613 | simdjson_inline error_code simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::rewind() noexcept { |
| 614 | if (error()) { return error(); } |
| 615 | first.rewind(); |
| 616 | return SUCCESS; |
| 617 | } |
| 618 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::begin() & noexcept { |
| 619 | if (error()) { return error(); } |
| 620 | return first.begin(); |
| 621 | } |
| 622 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::end() & noexcept { |
| 623 | return {}; |
| 624 | } |
| 625 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::find_field_unordered(std::string_view key) & noexcept { |
| 626 | if (error()) { return error(); } |
| 627 | return first.find_field_unordered(key); |
| 628 | } |
| 629 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::find_field_unordered(const char *key) & noexcept { |
| 630 | if (error()) { return error(); } |
| 631 | return first.find_field_unordered(key); |
| 632 | } |
| 633 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::operator[](std::string_view key) & noexcept { |
| 634 | if (error()) { return error(); } |
| 635 | return first[key]; |
| 636 | } |
| 637 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::operator[](const char *key) & noexcept { |
| 638 | if (error()) { return error(); } |
| 639 | return first[key]; |
| 640 | } |
| 641 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::find_field(std::string_view key) & noexcept { |
| 642 | if (error()) { return error(); } |
| 643 | return first.find_field(key); |
| 644 | } |
| 645 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::find_field(const char *key) & noexcept { |
| 646 | if (error()) { return error(); } |
| 647 | return first.find_field(key); |
| 648 | } |
| 649 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_array() & noexcept { |
| 650 | if (error()) { return error(); } |
| 651 | return first.get_array(); |
| 652 | } |
| 653 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_object() & noexcept { |
| 654 | if (error()) { return error(); } |
| 655 | return first.get_object(); |
| 656 | } |
| 657 | simdjson_inline simdjson_result<uint64_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_uint64() noexcept { |
| 658 | if (error()) { return error(); } |
| 659 | return first.get_uint64(); |
| 660 | } |
| 661 | simdjson_inline simdjson_result<uint64_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_uint64_in_string() noexcept { |
| 662 | if (error()) { return error(); } |
| 663 | return first.get_uint64_in_string(); |
| 664 | } |
| 665 | simdjson_inline simdjson_result<int64_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_int64() noexcept { |
| 666 | if (error()) { return error(); } |
| 667 | return first.get_int64(); |
| 668 | } |
| 669 | simdjson_inline simdjson_result<int64_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_int64_in_string() noexcept { |
| 670 | if (error()) { return error(); } |
| 671 | return first.get_int64_in_string(); |
| 672 | } |
| 673 | simdjson_inline simdjson_result<double> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_double() noexcept { |
| 674 | if (error()) { return error(); } |
| 675 | return first.get_double(); |
| 676 | } |
| 677 | simdjson_inline simdjson_result<double> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_double_in_string() noexcept { |
| 678 | if (error()) { return error(); } |
| 679 | return first.get_double_in_string(); |
| 680 | } |
| 681 | simdjson_inline simdjson_result<std::string_view> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_string(bool allow_replacement) noexcept { |
| 682 | if (error()) { return error(); } |
| 683 | return first.get_string(allow_replacement); |
| 684 | } |
| 685 | simdjson_inline simdjson_result<std::string_view> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_wobbly_string() noexcept { |
| 686 | if (error()) { return error(); } |
| 687 | return first.get_wobbly_string(); |
| 688 | } |
| 689 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_raw_json_string() noexcept { |
| 690 | if (error()) { return error(); } |
| 691 | return first.get_raw_json_string(); |
| 692 | } |
| 693 | simdjson_inline simdjson_result<bool> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_bool() noexcept { |
| 694 | if (error()) { return error(); } |
| 695 | return first.get_bool(); |
| 696 | } |
| 697 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_value() noexcept { |
| 698 | if (error()) { return error(); } |
| 699 | return first.get_value(); |
| 700 | } |
| 701 | simdjson_inline simdjson_result<bool> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::is_null() noexcept { |
| 702 | if (error()) { return error(); } |
| 703 | return first.is_null(); |
| 704 | } |
| 705 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::json_type> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::type() noexcept { |
| 706 | if (error()) { return error(); } |
| 707 | return first.type(); |
| 708 | } |
| 709 | simdjson_inline simdjson_result<bool> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::is_scalar() noexcept { |
| 710 | if (error()) { return error(); } |
| 711 | return first.is_scalar(); |
| 712 | } |
| 713 | simdjson_inline simdjson_result<bool> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::is_negative() noexcept { |
| 714 | if (error()) { return error(); } |
| 715 | return first.is_negative(); |
| 716 | } |
| 717 | simdjson_inline simdjson_result<bool> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::is_integer() noexcept { |
| 718 | if (error()) { return error(); } |
| 719 | return first.is_integer(); |
| 720 | } |
| 721 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::number_type> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_number_type() noexcept { |
| 722 | if (error()) { return error(); } |
| 723 | return first.get_number_type(); |
| 724 | } |
| 725 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::number> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_number() noexcept { |
| 726 | if (error()) { return error(); } |
| 727 | return first.get_number(); |
| 728 | } |
| 729 | #if SIMDJSON_EXCEPTIONS |
| 730 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::operator SIMDJSON_IMPLEMENTATION::ondemand::array() & noexcept(false) { |
| 731 | if (error()) { throw simdjson_error(error()); } |
| 732 | return first; |
| 733 | } |
| 734 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::operator SIMDJSON_IMPLEMENTATION::ondemand::object() & noexcept(false) { |
| 735 | if (error()) { throw simdjson_error(error()); } |
| 736 | return first; |
| 737 | } |
| 738 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::operator uint64_t() noexcept(false) { |
| 739 | if (error()) { throw simdjson_error(error()); } |
| 740 | return first; |
| 741 | } |
| 742 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::operator int64_t() noexcept(false) { |
| 743 | if (error()) { throw simdjson_error(error()); } |
| 744 | return first; |
| 745 | } |
| 746 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::operator double() noexcept(false) { |
| 747 | if (error()) { throw simdjson_error(error()); } |
| 748 | return first; |
| 749 | } |
| 750 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::operator std::string_view() noexcept(false) { |
| 751 | if (error()) { throw simdjson_error(error()); } |
| 752 | return first; |
| 753 | } |
| 754 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::operator SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string() noexcept(false) { |
| 755 | if (error()) { throw simdjson_error(error()); } |
| 756 | return first; |
| 757 | } |
| 758 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::operator bool() noexcept(false) { |
| 759 | if (error()) { throw simdjson_error(error()); } |
| 760 | return first; |
| 761 | } |
| 762 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::operator SIMDJSON_IMPLEMENTATION::ondemand::value() noexcept(false) { |
| 763 | if (error()) { throw simdjson_error(error()); } |
| 764 | return first; |
| 765 | } |
| 766 | #endif |
| 767 | |
| 768 | simdjson_inline simdjson_result<const char *> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::current_location() noexcept { |
| 769 | if (error()) { return error(); } |
| 770 | return first.current_location(); |
| 771 | } |
| 772 | |
| 773 | simdjson_inline simdjson_result<std::string_view> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::raw_json_token() noexcept { |
| 774 | if (error()) { return error(); } |
| 775 | return first.raw_json_token(); |
| 776 | } |
| 777 | |
| 778 | simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::at_pointer(std::string_view json_pointer) noexcept { |
| 779 | if (error()) { return error(); } |
| 780 | return first.at_pointer(json_pointer); |
| 781 | } |
| 782 | |
| 783 | |
| 784 | } // namespace simdjson |
| 785 | |