simdjson 4.1.0
Ridiculously Fast JSON
Loading...
Searching...
No Matches
field.h
1#ifndef SIMDJSON_GENERIC_ONDEMAND_FIELD_H
2
3#ifndef SIMDJSON_CONDITIONAL_INCLUDE
4#define SIMDJSON_GENERIC_ONDEMAND_FIELD_H
5#include "simdjson/generic/ondemand/base.h"
6#include "simdjson/generic/implementation_simdjson_result_base.h"
7#include "simdjson/generic/ondemand/raw_json_string.h"
8#include "simdjson/generic/ondemand/value.h"
9#endif // SIMDJSON_CONDITIONAL_INCLUDE
10
11namespace simdjson {
12namespace SIMDJSON_IMPLEMENTATION {
13namespace ondemand {
14
22class field : public std::pair<raw_json_string, value> {
23public:
29 simdjson_inline field() noexcept;
30
39 simdjson_inline simdjson_warn_unused simdjson_result<std::string_view> unescaped_key(bool allow_replacement = false) noexcept;
48 template <typename string_type>
49 simdjson_inline simdjson_warn_unused error_code unescaped_key(string_type& receiver, bool allow_replacement = false) noexcept;
57 simdjson_inline raw_json_string key() const noexcept;
64 simdjson_inline std::string_view key_raw_json_token() const noexcept;
71 simdjson_inline std::string_view escaped_key() const noexcept;
75 simdjson_inline ondemand::value &value() & noexcept;
79 simdjson_inline ondemand::value value() && noexcept;
80
81protected:
82 simdjson_inline field(raw_json_string key, ondemand::value &&value) noexcept;
83 static simdjson_inline simdjson_result<field> start(value_iterator &parent_iter) noexcept;
84 static simdjson_inline simdjson_result<field> start(const value_iterator &parent_iter, raw_json_string key) noexcept;
85 friend struct simdjson_result<field>;
86 friend class object_iterator;
87};
88
89} // namespace ondemand
90} // namespace SIMDJSON_IMPLEMENTATION
91} // namespace simdjson
92
93namespace simdjson {
94
95template<>
96struct simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::field> : public SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::field> {
97public:
98 simdjson_inline simdjson_result(SIMDJSON_IMPLEMENTATION::ondemand::field &&value) noexcept;
99 simdjson_inline simdjson_result(error_code error) noexcept;
100 simdjson_inline simdjson_result() noexcept = default;
101
102 simdjson_inline simdjson_result<std::string_view> unescaped_key(bool allow_replacement = false) noexcept;
103 template<typename string_type>
104 simdjson_inline error_code unescaped_key(string_type &receiver, bool allow_replacement = false) noexcept;
106 simdjson_inline simdjson_result<std::string_view> key_raw_json_token() noexcept;
107 simdjson_inline simdjson_result<std::string_view> escaped_key() noexcept;
108 simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> value() noexcept;
109};
110
111} // namespace simdjson
112
113#endif // SIMDJSON_GENERIC_ONDEMAND_FIELD_H
A JSON field (key/value pair) in an object.
Definition field.h:22
simdjson_inline std::string_view key_raw_json_token() const noexcept
Get the unprocessed key as a string_view.
Definition field-inl.h:55
simdjson_inline simdjson_warn_unused simdjson_result< std::string_view > unescaped_key(bool allow_replacement=false) noexcept
Get the key as a string_view (for higher speed, consider raw_key).
Definition field-inl.h:34
simdjson_inline raw_json_string key() const noexcept
Get the key as a raw_json_string.
Definition field-inl.h:49
simdjson_inline std::string_view escaped_key() const noexcept
Get the key as a string_view.
Definition field-inl.h:60
simdjson_inline field() noexcept
Create a new invalid field.
Definition field-inl.h:16
A string escaped per JSON rules, terminated with quote (").
An ephemeral JSON value returned during iteration.
Definition value.h:21
The top level simdjson namespace, containing everything the library provides.
Definition base.h:8
error_code
All possible errors returned by simdjson.
Definition error.h:19
The result of a simdjson operation that could fail.
Definition error.h:278
simdjson_inline error_code error() const noexcept
The error.
Definition error-inl.h:168