simdjson 5.0.2
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;
40#if SIMDJSON_SUPPORTS_CHAR8_T
48 simdjson_inline simdjson_warn_unused simdjson_result<std::u8string_view> unescaped_u8key(bool allow_replacement = false) noexcept;
49#endif // SIMDJSON_SUPPORTS_CHAR8_T
58 template <typename string_type>
59 simdjson_inline simdjson_warn_unused error_code unescaped_key(string_type& receiver, bool allow_replacement = false) noexcept;
67 simdjson_inline raw_json_string key() const noexcept;
74 simdjson_inline std::string_view key_raw_json_token() const noexcept;
81 simdjson_inline std::string_view escaped_key() const noexcept;
82#if SIMDJSON_SUPPORTS_CHAR8_T
90 simdjson_inline std::u8string_view escaped_u8key() const noexcept;
91#endif // SIMDJSON_SUPPORTS_CHAR8_T
95 simdjson_inline ondemand::value &value() & noexcept;
99 simdjson_inline ondemand::value value() && noexcept;
100
101protected:
102 simdjson_inline field(raw_json_string key, ondemand::value &&value) noexcept;
103 static simdjson_inline simdjson_result<field> start(value_iterator &parent_iter) noexcept;
104 static simdjson_inline simdjson_result<field> start(const value_iterator &parent_iter, raw_json_string key) noexcept;
105 friend struct simdjson_result<field>;
106 friend class object_iterator;
107};
108
109} // namespace ondemand
110} // namespace SIMDJSON_IMPLEMENTATION
111} // namespace simdjson
112
113namespace simdjson {
114
115template<>
116struct simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::field> : public SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::field> {
117public:
118 simdjson_inline simdjson_result(SIMDJSON_IMPLEMENTATION::ondemand::field &&value) noexcept;
119 simdjson_inline simdjson_result(error_code error) noexcept;
120 simdjson_inline simdjson_result() noexcept = default;
121
122 simdjson_inline simdjson_result<std::string_view> unescaped_key(bool allow_replacement = false) noexcept;
123#if SIMDJSON_SUPPORTS_CHAR8_T
124 simdjson_inline simdjson_result<std::u8string_view> unescaped_u8key(bool allow_replacement = false) noexcept;
125#endif // SIMDJSON_SUPPORTS_CHAR8_T
126 template<typename string_type>
127 simdjson_inline error_code unescaped_key(string_type &receiver, bool allow_replacement = false) noexcept;
129 simdjson_inline simdjson_result<std::string_view> key_raw_json_token() noexcept;
130 simdjson_inline simdjson_result<std::string_view> escaped_key() noexcept;
131#if SIMDJSON_SUPPORTS_CHAR8_T
132 simdjson_inline simdjson_result<std::u8string_view> escaped_u8key() noexcept;
133#endif // SIMDJSON_SUPPORTS_CHAR8_T
134 simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> value() noexcept;
135};
136
137} // namespace simdjson
138
139#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:63
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:57
simdjson_inline std::string_view escaped_key() const noexcept
Get the key as a string_view.
Definition field-inl.h:68
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:22
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:281
simdjson_inline error_code error() const noexcept
The error.
Definition error-inl.h:168