simdjson 4.2.1
Ridiculously Fast JSON
Loading...
Searching...
No Matches
raw_json_string.h
1#ifndef SIMDJSON_GENERIC_ONDEMAND_RAW_JSON_STRING_H
2
3#ifndef SIMDJSON_CONDITIONAL_INCLUDE
4#define SIMDJSON_GENERIC_ONDEMAND_RAW_JSON_STRING_H
5#include "simdjson/generic/ondemand/base.h"
6#include "simdjson/generic/implementation_simdjson_result_base.h"
7#endif // SIMDJSON_CONDITIONAL_INCLUDE
8
9namespace simdjson {
10namespace SIMDJSON_IMPLEMENTATION {
11namespace ondemand {
12
37public:
43 simdjson_inline raw_json_string() noexcept = default;
44
52 simdjson_inline raw_json_string(const uint8_t * _buf) noexcept;
59 simdjson_inline const char * raw() const noexcept;
60
65 simdjson_inline char operator[](size_t i) const noexcept;
66
81 simdjson_inline bool unsafe_is_equal(size_t length, std::string_view target) const noexcept;
82
98 simdjson_inline bool unsafe_is_equal(std::string_view target) const noexcept;
99
112 simdjson_inline bool unsafe_is_equal(const char* target) const noexcept;
113
118 simdjson_inline bool is_equal(std::string_view target) const noexcept;
119
124 simdjson_inline bool is_equal(const char* target) const noexcept;
125
131 static simdjson_inline bool is_free_from_unescaped_quote(std::string_view target) noexcept;
132 static simdjson_inline bool is_free_from_unescaped_quote(const char* target) noexcept;
133
134private:
135
136
141 simdjson_inline void consume() noexcept { buf = nullptr; }
142
146 simdjson_inline simdjson_warn_unused bool alive() const noexcept { return buf != nullptr; }
147
159 simdjson_inline simdjson_warn_unused simdjson_result<std::string_view> unescape(json_iterator &iter, bool allow_replacement) const noexcept;
160
171 simdjson_inline simdjson_warn_unused simdjson_result<std::string_view> unescape_wobbly(json_iterator &iter) const noexcept;
172 const uint8_t * buf{};
173 friend class object;
174 friend class field;
175 friend class parser;
176 friend struct simdjson_result<raw_json_string>;
177};
178
179simdjson_unused simdjson_inline std::ostream &operator<<(std::ostream &, const raw_json_string &) noexcept;
180
185simdjson_unused simdjson_inline bool operator==(const raw_json_string &a, std::string_view c) noexcept;
186simdjson_unused simdjson_inline bool operator==(std::string_view c, const raw_json_string &a) noexcept;
187simdjson_unused simdjson_inline bool operator!=(const raw_json_string &a, std::string_view c) noexcept;
188simdjson_unused simdjson_inline bool operator!=(std::string_view c, const raw_json_string &a) noexcept;
189
190
191} // namespace ondemand
192} // namespace SIMDJSON_IMPLEMENTATION
193} // namespace simdjson
194
195namespace simdjson {
196
197template<>
198struct simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string> : public SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string> {
199public:
200 simdjson_inline simdjson_result(SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string &&value) noexcept;
201 simdjson_inline simdjson_result(error_code error) noexcept;
202 simdjson_inline simdjson_result() noexcept = default;
203 simdjson_inline ~simdjson_result() noexcept = default;
204
205 simdjson_inline simdjson_result<const char *> raw() const noexcept;
206 simdjson_inline char operator[](size_t) const noexcept;
207 simdjson_inline simdjson_warn_unused simdjson_result<std::string_view> unescape(SIMDJSON_IMPLEMENTATION::ondemand::json_iterator &iter, bool allow_replacement) const noexcept;
208 simdjson_inline simdjson_warn_unused simdjson_result<std::string_view> unescape_wobbly(SIMDJSON_IMPLEMENTATION::ondemand::json_iterator &iter) const noexcept;
209};
210} // namespace simdjson
211
212#endif // SIMDJSON_GENERIC_ONDEMAND_RAW_JSON_STRING_H
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...
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