simdjson  3.1.1
Ridiculously Fast JSON
raw_json_string.h
1 #include "simdjson/error.h"
2 
3 namespace simdjson {
4 namespace SIMDJSON_IMPLEMENTATION {
5 namespace ondemand {
6 
7 class object;
8 class parser;
9 class json_iterator;
10 
35 public:
41  simdjson_inline raw_json_string() noexcept = default;
42 
50  simdjson_inline raw_json_string(const uint8_t * _buf) noexcept;
57  simdjson_inline const char * raw() const noexcept;
58 
73  simdjson_inline bool unsafe_is_equal(size_t length, std::string_view target) const noexcept;
74 
90  simdjson_inline bool unsafe_is_equal(std::string_view target) const noexcept;
91 
104  simdjson_inline bool unsafe_is_equal(const char* target) const noexcept;
105 
110  simdjson_inline bool is_equal(std::string_view target) const noexcept;
111 
116  simdjson_inline bool is_equal(const char* target) const noexcept;
117 
123  static simdjson_inline bool is_free_from_unescaped_quote(std::string_view target) noexcept;
124  static simdjson_inline bool is_free_from_unescaped_quote(const char* target) noexcept;
125 
126 private:
127 
128 
133  simdjson_inline void consume() noexcept { buf = nullptr; }
134 
138  simdjson_inline simdjson_warn_unused bool alive() const noexcept { return buf != nullptr; }
139 
149  simdjson_inline simdjson_warn_unused simdjson_result<std::string_view> unescape(json_iterator &iter) const noexcept;
150 
151  const uint8_t * buf{};
152  friend class object;
153  friend class field;
154  friend class parser;
155  friend struct simdjson_result<raw_json_string>;
156 };
157 
158 simdjson_unused simdjson_inline std::ostream &operator<<(std::ostream &, const raw_json_string &) noexcept;
159 
164 simdjson_unused simdjson_inline bool operator==(const raw_json_string &a, std::string_view c) noexcept;
165 simdjson_unused simdjson_inline bool operator==(std::string_view c, const raw_json_string &a) noexcept;
166 simdjson_unused simdjson_inline bool operator!=(const raw_json_string &a, std::string_view c) noexcept;
167 simdjson_unused simdjson_inline bool operator!=(std::string_view c, const raw_json_string &a) noexcept;
168 
169 
170 } // namespace ondemand
171 } // namespace SIMDJSON_IMPLEMENTATION
172 } // namespace simdjson
173 
174 namespace simdjson {
175 
176 template<>
177 struct simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string> : public SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string> {
178 public:
180  simdjson_inline simdjson_result(error_code error) noexcept;
181  simdjson_inline simdjson_result() noexcept = default;
182  simdjson_inline ~simdjson_result() noexcept = default;
183 
184  simdjson_inline simdjson_result<const char *> raw() const noexcept;
185  simdjson_inline simdjson_warn_unused simdjson_result<std::string_view> unescape(SIMDJSON_IMPLEMENTATION::ondemand::json_iterator &iter) const noexcept;
186 };
187 
188 } // namespace simdjson
A string escaped per JSON rules, terminated with quote (").
simdjson_inline bool is_equal(std::string_view target) const noexcept
This compares the current instance to the std::string_view target: returns true if they are byte-by-b...
static simdjson_inline bool is_free_from_unescaped_quote(std::string_view target) noexcept
Returns true if target is free from unescaped quote.
simdjson_inline raw_json_string() noexcept=default
Create a new invalid raw_json_string.
simdjson_inline const char * raw() const noexcept
Get the raw pointer to the beginning of the string in the JSON (just after the ").
simdjson_inline bool unsafe_is_equal(size_t length, std::string_view target) const noexcept
This compares the current instance to the std::string_view target: returns true if they are byte-by-b...
simdjson_unused simdjson_inline bool operator==(const raw_json_string &a, std::string_view c) noexcept
Comparisons between raw_json_string and std::string_view instances are potentially unsafe: the user i...
std::ostream & operator<<(std::ostream &out, json_type type) noexcept
Write the JSON type to the output stream.
Definition: json_type-inl.h:5
@ object
A JSON object ( { "a": 1, "b" 2, ... } )
We want to support argument-dependent lookup (ADL).
error_code
All possible errors returned by simdjson.
Definition: error.h:17
The result of a simdjson operation that could fail.
Definition: error.h:205
simdjson_inline error_code error() const noexcept
The error.
Definition: error-inl.h:132
simdjson_inline T & value() &noexcept(false)
Get the result value.