3 namespace SIMDJSON_IMPLEMENTATION {
8 simdjson_inline
const char *
raw_json_string::raw() const noexcept {
return reinterpret_cast<const char *
>(buf); }
14 for(;pos < target.size() && target[pos] !=
'\\';pos++) {}
17 for(;pos < target.size();pos++) {
18 if((target[pos] ==
'"') && !escaping) {
20 }
else if(target[pos] ==
'\\') {
32 for(;target[pos] && target[pos] !=
'\\';pos++) {}
35 for(;target[pos];pos++) {
36 if((target[pos] ==
'"') && !escaping) {
38 }
else if(target[pos] ==
'\\') {
50 return (length >= target.size()) && (raw()[target.size()] ==
'"') && !memcmp(raw(), target.data(), target.size());
57 return (raw()[target.size()] ==
'"') && !memcmp(raw(), target.data(), target.size());
59 const char * r{raw()};
61 for(;pos < target.size();pos++) {
62 if(r[pos] != target[pos]) {
return false; }
64 if(r[pos] !=
'"') {
return false; }
69 const char * r{raw()};
72 for(;pos < target.size();pos++) {
73 if(r[pos] != target[pos]) {
return false; }
77 if((target[pos] ==
'"') && !escaping) {
81 }
else if(target[pos] ==
'\\') {
87 if(r[pos] !=
'"') {
return false; }
95 const char * r{raw()};
97 for(;target[pos];pos++) {
98 if(r[pos] != target[pos]) {
return false; }
100 if(r[pos] !=
'"') {
return false; }
107 const char * r{raw()};
109 bool escaping{
false};
110 for(;target[pos];pos++) {
111 if(r[pos] != target[pos]) {
return false; }
115 if((target[pos] ==
'"') && !escaping) {
119 }
else if(target[pos] ==
'\\') {
120 escaping = !escaping;
125 if(r[pos] !=
'"') {
return false; }
130 return a.unsafe_is_equal(c);
133 simdjson_unused simdjson_inline
bool operator==(std::string_view c,
const raw_json_string &a) noexcept {
137 simdjson_unused simdjson_inline
bool operator!=(
const raw_json_string &a, std::string_view c) noexcept {
141 simdjson_unused simdjson_inline
bool operator!=(std::string_view c,
const raw_json_string &a) noexcept {
146 simdjson_inline simdjson_warn_unused simdjson_result<std::string_view> raw_json_string::unescape(json_iterator &iter,
bool allow_replacement)
const noexcept {
147 return iter.unescape(*
this, allow_replacement);
150 simdjson_inline simdjson_warn_unused simdjson_result<std::string_view> raw_json_string::unescape_wobbly(json_iterator &iter)
const noexcept {
151 return iter.unescape_wobbly(*
this);
154 simdjson_unused simdjson_inline std::ostream &
operator<<(std::ostream &out,
const raw_json_string &str) noexcept {
155 bool in_escape =
false;
156 const char *s = str.raw();
159 case '\\': in_escape = !in_escape;
break;
160 case '"':
if (in_escape) { in_escape =
false; }
else {
return out; }
break;
161 default:
if (in_escape) { in_escape =
false; }
174 simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string>::simdjson_result(SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string &&value) noexcept
175 : implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string>(std::forward<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string>(value)) {}
176 simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string>::simdjson_result(
error_code error) noexcept
177 : implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string>(error) {}
179 simdjson_inline simdjson_result<const char *> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string>::raw() const noexcept {
183 simdjson_inline simdjson_warn_unused simdjson_result<std::string_view> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string>::unescape(SIMDJSON_IMPLEMENTATION::ondemand::json_iterator &iter,
bool allow_replacement)
const noexcept {
184 if (error()) {
return error(); }
185 return first.unescape(iter, allow_replacement);
187 simdjson_inline simdjson_warn_unused simdjson_result<std::string_view> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string>::unescape_wobbly(SIMDJSON_IMPLEMENTATION::ondemand::json_iterator &iter)
const noexcept {
188 if (error()) {
return error(); }
189 return first.unescape_wobbly(iter);
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.
We want to support argument-dependent lookup (ADL).
error_code
All possible errors returned by simdjson.
constexpr size_t SIMDJSON_PADDING
The amount of padding needed in a buffer to parse JSON.
simdjson_inline error_code error() const noexcept
The error.