Allow reuse of value to try multiple types
This commit is contained in:
parent
ba02cda55f
commit
c7c1372833
|
@ -22,12 +22,12 @@ private:
|
|||
|
||||
simdjson_really_inline simdjson_result<double> first_double(ondemand::json_iterator &iter, const char *key) {
|
||||
if (!iter.start_object() || ondemand::raw_json_string(iter.field_key()) != key || iter.field_value()) { throw "Invalid field"; }
|
||||
return iter.get_double();
|
||||
return iter.consume_double();
|
||||
}
|
||||
|
||||
simdjson_really_inline simdjson_result<double> next_double(ondemand::json_iterator &iter, const char *key) {
|
||||
if (!iter.has_next_field() || ondemand::raw_json_string(iter.field_key()) != key || iter.field_value()) { throw "Invalid field"; }
|
||||
return iter.get_double();
|
||||
return iter.consume_double();
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -76,11 +76,11 @@ simdjson_really_inline bool Iter::Run(const padded_string &json) {
|
|||
if (!iter.start_array()) { return false; }
|
||||
do {
|
||||
if (!iter.start_object() || !iter.find_field_raw("x")) { return false; }
|
||||
sum.x += iter.get_double();
|
||||
sum.x += iter.consume_double();
|
||||
if (!iter.has_next_field() || !iter.find_field_raw("y")) { return false; }
|
||||
sum.y += iter.get_double();
|
||||
sum.y += iter.consume_double();
|
||||
if (!iter.has_next_field() || !iter.find_field_raw("z")) { return false; }
|
||||
sum.z += iter.get_double();
|
||||
sum.z += iter.consume_double();
|
||||
if (iter.skip_container()) { return false; } // Skip the rest of the coordinates object
|
||||
count++;
|
||||
} while (iter.has_next_element());
|
||||
|
|
|
@ -22,12 +22,12 @@ private:
|
|||
|
||||
simdjson_really_inline double first_double(ondemand::json_iterator &iter) {
|
||||
if (iter.start_object().error() || iter.field_key().error() || iter.field_value()) { throw "Invalid field"; }
|
||||
return iter.get_double();
|
||||
return iter.consume_double();
|
||||
}
|
||||
|
||||
simdjson_really_inline double next_double(ondemand::json_iterator &iter) {
|
||||
if (!iter.has_next_field() || iter.field_key().error() || iter.field_value()) { throw "Invalid field"; }
|
||||
return iter.get_double();
|
||||
return iter.consume_double();
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -72,11 +72,11 @@ simdjson_really_inline bool Iter::Run(const padded_string &json) {
|
|||
if (!iter.start_array()) { return false; }
|
||||
do {
|
||||
if (!iter.start_object() || iter.field_key().value() != "x" || iter.field_value()) { return false; }
|
||||
sum.x += iter.get_double();
|
||||
sum.x += iter.consume_double();
|
||||
if (!iter.has_next_field() || iter.field_key().value() != "y" || iter.field_value()) { return false; }
|
||||
sum.y += iter.get_double();
|
||||
sum.y += iter.consume_double();
|
||||
if (!iter.has_next_field() || iter.field_key().value() != "z" || iter.field_value()) { return false; }
|
||||
sum.z += iter.get_double();
|
||||
sum.z += iter.consume_double();
|
||||
if (*iter.advance() != '}') { return false; }
|
||||
count++;
|
||||
} while (iter.has_next_element());
|
||||
|
|
|
@ -47,35 +47,35 @@ simdjson_really_inline bool Iter::Run(const padded_string &json) {
|
|||
tweet tweet;
|
||||
|
||||
if (!iter.start_object() || !iter.find_field_raw("created_at")) { return false; }
|
||||
tweet.created_at = iter.get_raw_json_string().value().unescape(iter);
|
||||
tweet.created_at = iter.consume_raw_json_string().value().unescape(iter);
|
||||
|
||||
if (!iter.has_next_field() || !iter.find_field_raw("id")) { return false; }
|
||||
tweet.id = iter.get_uint64();
|
||||
tweet.id = iter.consume_uint64();
|
||||
|
||||
if (!iter.has_next_field() || !iter.find_field_raw("text")) { return false; }
|
||||
tweet.text = iter.get_raw_json_string().value().unescape(iter);
|
||||
tweet.text = iter.consume_raw_json_string().value().unescape(iter);
|
||||
|
||||
if (!iter.has_next_field() || !iter.find_field_raw("in_reply_to_status_id")) { return false; }
|
||||
if (!iter.is_null()) {
|
||||
tweet.in_reply_to_status_id = iter.get_uint64();
|
||||
tweet.in_reply_to_status_id = iter.consume_uint64();
|
||||
}
|
||||
|
||||
if (!iter.has_next_field() || !iter.find_field_raw("user")) { return false; }
|
||||
{
|
||||
if (!iter.start_object() || !iter.find_field_raw("id")) { return false; }
|
||||
tweet.user.id = iter.get_uint64();
|
||||
tweet.user.id = iter.consume_uint64();
|
||||
|
||||
if (!iter.has_next_field() || !iter.find_field_raw("screen_name")) { return false; }
|
||||
tweet.user.screen_name = iter.get_raw_json_string().value().unescape(iter);
|
||||
tweet.user.screen_name = iter.consume_raw_json_string().value().unescape(iter);
|
||||
|
||||
if (iter.skip_container()) { return false; } // Skip the rest of the user object
|
||||
}
|
||||
|
||||
if (!iter.has_next_field() || !iter.find_field_raw("retweet_count")) { return false; }
|
||||
tweet.retweet_count = iter.get_uint64();
|
||||
tweet.retweet_count = iter.consume_uint64();
|
||||
|
||||
if (!iter.has_next_field() || !iter.find_field_raw("favorite_count")) { return false; }
|
||||
tweet.favorite_count = iter.get_uint64();
|
||||
tweet.favorite_count = iter.consume_uint64();
|
||||
|
||||
tweets.push_back(tweet);
|
||||
|
||||
|
|
|
@ -41,15 +41,15 @@ simdjson_really_inline simdjson_result<object> document::get_object() & noexcept
|
|||
}
|
||||
simdjson_really_inline simdjson_result<uint64_t> document::get_uint64() noexcept {
|
||||
assert_at_start();
|
||||
return consume_if_success( iter.get_root_uint64() );
|
||||
return consume_if_success( iter.parse_uint64(json) );
|
||||
}
|
||||
simdjson_really_inline simdjson_result<int64_t> document::get_int64() noexcept {
|
||||
assert_at_start();
|
||||
return consume_if_success( iter.get_root_int64() );
|
||||
return consume_if_success( iter.parse_root_int64(json) );
|
||||
}
|
||||
simdjson_really_inline simdjson_result<double> document::get_double() noexcept {
|
||||
assert_at_start();
|
||||
return consume_if_success( iter.get_root_double() );
|
||||
return consume_if_success( iter.parse_root_double(json) );
|
||||
}
|
||||
simdjson_really_inline simdjson_result<std::string_view> document::get_string() & noexcept {
|
||||
return consume_if_success( as_value().get_string() );
|
||||
|
@ -59,11 +59,11 @@ simdjson_really_inline simdjson_result<raw_json_string> document::get_raw_json_s
|
|||
}
|
||||
simdjson_really_inline simdjson_result<bool> document::get_bool() noexcept {
|
||||
assert_at_start();
|
||||
return consume_if_success( iter.get_root_bool() );
|
||||
return consume_if_success( iter.parse_root_bool(json) );
|
||||
}
|
||||
simdjson_really_inline bool document::is_null() noexcept {
|
||||
assert_at_start();
|
||||
if (iter.root_is_null()) { json = nullptr; return true; }
|
||||
if (iter.root_is_null(json)) { json = nullptr; return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,10 +40,13 @@ simdjson_really_inline json_iterator::~json_iterator() noexcept {
|
|||
}
|
||||
#endif
|
||||
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<bool> json_iterator::start_object() noexcept {
|
||||
if (*advance() != '{') { return report_error(INCORRECT_TYPE, "Not an object"); }
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<bool> json_iterator::start_object(const uint8_t *json) noexcept {
|
||||
if (*json != '{') { logger::log_error(*this, "Not an object"); return INCORRECT_TYPE; }
|
||||
return started_object();
|
||||
}
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<bool> json_iterator::start_object() noexcept {
|
||||
return start_object(advance());
|
||||
}
|
||||
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline bool json_iterator::started_object() noexcept {
|
||||
if (*peek() == '}') {
|
||||
|
@ -71,7 +74,7 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<bool> json_iterator:
|
|||
bool has_next;
|
||||
do {
|
||||
raw_json_string actual_key;
|
||||
SIMDJSON_TRY( get_raw_json_string().get(actual_key) );
|
||||
SIMDJSON_TRY( consume_raw_json_string().get(actual_key) );
|
||||
if (*advance() != ':') { return report_error(TAPE_ERROR, "Missing colon in object field"); }
|
||||
if (actual_key == key) {
|
||||
logger::log_event(*this, "match", key);
|
||||
|
@ -97,11 +100,15 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline error_code json_iterator::field_valu
|
|||
return SUCCESS;
|
||||
}
|
||||
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<bool> json_iterator::start_array() noexcept {
|
||||
if (*advance() != '[') { return report_error(INCORRECT_TYPE, "Not an array"); }
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<bool> json_iterator::start_array(const uint8_t *json) noexcept {
|
||||
if (*json != '[') { logger::log_error(*this, "Not an array"); return INCORRECT_TYPE; }
|
||||
return started_array();
|
||||
}
|
||||
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<bool> json_iterator::start_array() noexcept {
|
||||
return start_array(advance());
|
||||
}
|
||||
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline bool json_iterator::started_array() noexcept {
|
||||
if (*peek() == ']') {
|
||||
logger::log_value(*this, "empty array");
|
||||
|
@ -124,35 +131,61 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<bool> json_iterator:
|
|||
}
|
||||
}
|
||||
|
||||
SIMDJSON_WARN_UNUSED simdjson_result<raw_json_string> json_iterator::get_raw_json_string() noexcept {
|
||||
SIMDJSON_WARN_UNUSED simdjson_result<std::string_view> json_iterator::parse_string(const uint8_t *json) noexcept {
|
||||
return parse_raw_json_string(json).unescape(current_string_buf_loc);
|
||||
}
|
||||
SIMDJSON_WARN_UNUSED simdjson_result<std::string_view> json_iterator::consume_string() noexcept {
|
||||
return parse_string(advance());
|
||||
}
|
||||
SIMDJSON_WARN_UNUSED simdjson_result<raw_json_string> json_iterator::parse_raw_json_string(const uint8_t *json) noexcept {
|
||||
logger::log_value(*this, "string", "", 0);
|
||||
return raw_json_string(advance()+1);
|
||||
if (*json != '"') { logger::log_error(*this, "Not a string"); return INCORRECT_TYPE; }
|
||||
return raw_json_string(json+1);
|
||||
}
|
||||
SIMDJSON_WARN_UNUSED simdjson_result<uint64_t> json_iterator::get_uint64() noexcept {
|
||||
SIMDJSON_WARN_UNUSED simdjson_result<raw_json_string> json_iterator::consume_raw_json_string() noexcept {
|
||||
return parse_raw_json_string(advance());
|
||||
}
|
||||
SIMDJSON_WARN_UNUSED simdjson_result<uint64_t> json_iterator::parse_uint64(const uint8_t *json) noexcept {
|
||||
logger::log_value(*this, "uint64", "", 0);
|
||||
return numberparsing::parse_unsigned(advance());
|
||||
return numberparsing::parse_unsigned(json);
|
||||
}
|
||||
SIMDJSON_WARN_UNUSED simdjson_result<int64_t> json_iterator::get_int64() noexcept {
|
||||
SIMDJSON_WARN_UNUSED simdjson_result<uint64_t> json_iterator::consume_uint64() noexcept {
|
||||
return parse_uint64(advance());
|
||||
}
|
||||
SIMDJSON_WARN_UNUSED simdjson_result<int64_t> json_iterator::parse_int64(const uint8_t *json) noexcept {
|
||||
logger::log_value(*this, "int64", "", 0);
|
||||
return numberparsing::parse_integer(advance());
|
||||
return numberparsing::parse_integer(json);
|
||||
}
|
||||
SIMDJSON_WARN_UNUSED simdjson_result<double> json_iterator::get_double() noexcept {
|
||||
SIMDJSON_WARN_UNUSED simdjson_result<int64_t> json_iterator::consume_int64() noexcept {
|
||||
return parse_int64(advance());
|
||||
}
|
||||
SIMDJSON_WARN_UNUSED simdjson_result<double> json_iterator::parse_double(const uint8_t *json) noexcept {
|
||||
logger::log_value(*this, "double", "", 0);
|
||||
return numberparsing::parse_double(advance());
|
||||
return numberparsing::parse_double(json);
|
||||
}
|
||||
SIMDJSON_WARN_UNUSED simdjson_result<bool> json_iterator::get_bool() noexcept {
|
||||
SIMDJSON_WARN_UNUSED simdjson_result<double> json_iterator::consume_double() noexcept {
|
||||
return parse_double(advance());
|
||||
}
|
||||
SIMDJSON_WARN_UNUSED simdjson_result<bool> json_iterator::parse_bool(const uint8_t *json) noexcept {
|
||||
logger::log_value(*this, "bool", "", 0);
|
||||
auto json = advance();
|
||||
auto not_true = atomparsing::str4ncmp(json, "true");
|
||||
auto not_false = atomparsing::str4ncmp(json, "fals") | (json[4] ^ 'e');
|
||||
bool error = (not_true && not_false) || jsoncharutils::is_not_structural_or_whitespace(json[not_true ? 5 : 4]);
|
||||
if (error) { return report_error(INCORRECT_TYPE, "not a boolean"); }
|
||||
if (error) { logger::log_error(*this, "Not a boolean"); return INCORRECT_TYPE; }
|
||||
return simdjson_result<bool>(!not_true);
|
||||
}
|
||||
simdjson_really_inline bool json_iterator::is_null() noexcept {
|
||||
auto json = peek();
|
||||
SIMDJSON_WARN_UNUSED simdjson_result<bool> json_iterator::consume_bool() noexcept {
|
||||
return parse_bool(advance());
|
||||
}
|
||||
simdjson_really_inline bool json_iterator::is_null(const uint8_t *json) noexcept {
|
||||
if (!atomparsing::str4ncmp(json, "null")) {
|
||||
logger::log_value(*this, "null", "", 0);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
simdjson_really_inline bool json_iterator::is_null() noexcept {
|
||||
if (is_null(peek())) {
|
||||
advance();
|
||||
return true;
|
||||
}
|
||||
|
@ -160,10 +193,9 @@ simdjson_really_inline bool json_iterator::is_null() noexcept {
|
|||
}
|
||||
|
||||
template<int N>
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline bool json_iterator::advance_to_buffer(uint8_t (&tmpbuf)[N]) noexcept {
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline bool json_iterator::copy_to_buffer(const uint8_t *json, uint8_t (&tmpbuf)[N]) noexcept {
|
||||
// Truncate whitespace to fit the buffer.
|
||||
auto len = peek_length();
|
||||
auto json = advance();
|
||||
auto len = peek_length(-1);
|
||||
if (len > N-1) {
|
||||
if (jsoncharutils::is_not_structural_or_whitespace(json[N])) { return false; }
|
||||
len = N-1;
|
||||
|
@ -177,39 +209,51 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline bool json_iterator::advance_to_buffe
|
|||
|
||||
constexpr const uint32_t MAX_INT_LENGTH = 1024;
|
||||
|
||||
SIMDJSON_WARN_UNUSED simdjson_result<uint64_t> json_iterator::get_root_uint64() noexcept {
|
||||
SIMDJSON_WARN_UNUSED simdjson_result<uint64_t> json_iterator::parse_root_uint64(const uint8_t *json) noexcept {
|
||||
uint8_t tmpbuf[20+1]; // <20 digits> is the longest possible unsigned integer
|
||||
if (!advance_to_buffer(tmpbuf)) { return report_error(NUMBER_ERROR, "Root number more than 20 digits"); }
|
||||
if (!copy_to_buffer(json, tmpbuf)) { logger::log_error(*this, "Root number more than 20 characters"); return NUMBER_ERROR; }
|
||||
logger::log_value(*this, "uint64", "", 0);
|
||||
auto result = numberparsing::parse_unsigned(buf);
|
||||
if (result.error()) { report_error(result.error(), "Error parsing unsigned integer"); }
|
||||
if (result.error()) { logger::log_error(*this, "Error parsing unsigned integer"); return result.error(); }
|
||||
return result;
|
||||
}
|
||||
SIMDJSON_WARN_UNUSED simdjson_result<int64_t> json_iterator::get_root_int64() noexcept {
|
||||
SIMDJSON_WARN_UNUSED simdjson_result<uint64_t> json_iterator::consume_root_uint64() noexcept {
|
||||
return parse_root_uint64(advance());
|
||||
}
|
||||
SIMDJSON_WARN_UNUSED simdjson_result<int64_t> json_iterator::parse_root_int64(const uint8_t *json) noexcept {
|
||||
uint8_t tmpbuf[20+1]; // -<19 digits> is the longest possible integer
|
||||
if (!advance_to_buffer(tmpbuf)) { return report_error(NUMBER_ERROR, "Root number more than 20 characters"); }
|
||||
if (!copy_to_buffer(json, tmpbuf)) { logger::log_error(*this, "Root number more than 20 characters"); return NUMBER_ERROR; }
|
||||
logger::log_value(*this, "int64", "", 0);
|
||||
auto result = numberparsing::parse_integer(buf);
|
||||
if (result.error()) { report_error(result.error(), "Error parsing integer"); }
|
||||
return result;
|
||||
}
|
||||
SIMDJSON_WARN_UNUSED simdjson_result<double> json_iterator::get_root_double() noexcept {
|
||||
SIMDJSON_WARN_UNUSED simdjson_result<int64_t> json_iterator::consume_root_int64() noexcept {
|
||||
return parse_root_int64(advance());
|
||||
}
|
||||
SIMDJSON_WARN_UNUSED simdjson_result<double> json_iterator::parse_root_double(const uint8_t *json) noexcept {
|
||||
// Per https://www.exploringbinary.com/maximum-number-of-decimal-digits-in-binary-floating-point-numbers/, 1074 is the maximum number of significant fractional digits. Add 8 more digits for the biggest number: -0.<fraction>e-308.
|
||||
uint8_t tmpbuf[1074+8+1];
|
||||
if (!advance_to_buffer(tmpbuf)) { return report_error(NUMBER_ERROR, "Root float more than 1082 digits"); }
|
||||
if (!copy_to_buffer(json, tmpbuf)) { logger::log_error(*this, "Root number more than 1082 characters"); return NUMBER_ERROR; }
|
||||
logger::log_value(*this, "double", "", 0);
|
||||
auto result = numberparsing::parse_double(buf);
|
||||
if (result.error()) { report_error(result.error(), "Error parsing double"); }
|
||||
return result;
|
||||
}
|
||||
SIMDJSON_WARN_UNUSED simdjson_result<bool> json_iterator::get_root_bool() noexcept {
|
||||
uint8_t tmpbuf[5+1];
|
||||
if (!advance_to_buffer(tmpbuf)) { return INCORRECT_TYPE; } // Too big! Can't be true or false
|
||||
return get_bool();
|
||||
SIMDJSON_WARN_UNUSED simdjson_result<double> json_iterator::consume_root_double() noexcept {
|
||||
return parse_root_double(advance());
|
||||
}
|
||||
simdjson_really_inline bool json_iterator::root_is_null() noexcept {
|
||||
SIMDJSON_WARN_UNUSED simdjson_result<bool> json_iterator::parse_root_bool(const uint8_t *json) noexcept {
|
||||
uint8_t tmpbuf[5+1];
|
||||
if (!copy_to_buffer(json, tmpbuf)) { logger::log_error(*this, "Not a boolean"); return INCORRECT_TYPE; }
|
||||
return consume_bool();
|
||||
}
|
||||
SIMDJSON_WARN_UNUSED simdjson_result<bool> json_iterator::consume_root_bool() noexcept {
|
||||
return parse_root_bool(advance());
|
||||
}
|
||||
simdjson_really_inline bool json_iterator::root_is_null(const uint8_t *json) noexcept {
|
||||
uint8_t tmpbuf[4+1];
|
||||
if (!advance_to_buffer(tmpbuf)) { return false; } // Too big! Can't be null
|
||||
if (!copy_to_buffer(json, tmpbuf)) { return false; }
|
||||
return is_null();
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,14 @@ public:
|
|||
simdjson_really_inline json_iterator(const json_iterator &other) noexcept = delete;
|
||||
simdjson_really_inline json_iterator &operator=(const json_iterator &other) noexcept = delete;
|
||||
|
||||
/**
|
||||
* Check for an opening { and start an object iteration.
|
||||
*
|
||||
* @param json A pointer to the potential {
|
||||
* @returns Whether the object had any fields (returns false for empty).
|
||||
* @error INCORRECT_TYPE if there is no opening {
|
||||
*/
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<bool> start_object(const uint8_t *json) noexcept;
|
||||
/**
|
||||
* Check for an opening { and start an object iteration.
|
||||
*
|
||||
|
@ -79,6 +87,14 @@ public:
|
|||
*/
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<bool> find_field_raw(const char *key) noexcept;
|
||||
|
||||
/**
|
||||
* Check for an opening [ and start an array iteration.
|
||||
*
|
||||
* @param json A pointer to the potential [.
|
||||
* @returns Whether the array had any elements (returns false for empty).
|
||||
* @error INCORRECT_TYPE If there is no [.
|
||||
*/
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<bool> start_array(const uint8_t *json) noexcept;
|
||||
/**
|
||||
* Check for an opening [ and start an array iteration.
|
||||
*
|
||||
|
@ -107,18 +123,31 @@ public:
|
|||
*/
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<bool> has_next_element() noexcept;
|
||||
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<raw_json_string> get_raw_json_string() noexcept;
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<uint64_t> get_uint64() noexcept;
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<int64_t> get_int64() noexcept;
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<double> get_double() noexcept;
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<bool> get_bool() noexcept;
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<std::string_view> parse_string(const uint8_t *json) noexcept;
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<std::string_view> consume_string() noexcept;
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<raw_json_string> parse_raw_json_string(const uint8_t *json) noexcept;
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<raw_json_string> consume_raw_json_string() noexcept;
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<uint64_t> parse_uint64(const uint8_t *json) noexcept;
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<uint64_t> consume_uint64() noexcept;
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<int64_t> parse_int64(const uint8_t *json) noexcept;
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<int64_t> consume_int64() noexcept;
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<double> parse_double(const uint8_t *json) noexcept;
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<double> consume_double() noexcept;
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<bool> parse_bool(const uint8_t *json) noexcept;
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<bool> consume_bool() noexcept;
|
||||
simdjson_really_inline bool is_null(const uint8_t *json) noexcept;
|
||||
simdjson_really_inline bool is_null() noexcept;
|
||||
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<uint64_t> get_root_uint64() noexcept;
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<int64_t> get_root_int64() noexcept;
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<double> get_root_double() noexcept;
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<bool> get_root_bool() noexcept;
|
||||
simdjson_really_inline bool root_is_null() noexcept;
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<uint64_t> parse_root_uint64(const uint8_t *json) noexcept;
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<uint64_t> consume_root_uint64() noexcept;
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<int64_t> parse_root_int64(const uint8_t *json) noexcept;
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<int64_t> consume_root_int64() noexcept;
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<double> parse_root_double(const uint8_t *json) noexcept;
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<double> consume_root_double() noexcept;
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<bool> parse_root_bool(const uint8_t *json) noexcept;
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result<bool> consume_root_bool() noexcept;
|
||||
simdjson_really_inline bool root_is_null(const uint8_t *json) noexcept;
|
||||
simdjson_really_inline bool root_is_null() & noexcept;
|
||||
|
||||
/**
|
||||
* Skips a JSON value, whether it is a scalar, array or object.
|
||||
|
@ -185,7 +214,7 @@ protected:
|
|||
|
||||
simdjson_really_inline json_iterator(ondemand::parser *parser) noexcept;
|
||||
template<int N>
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline bool advance_to_buffer(uint8_t (&buf)[N]) noexcept;
|
||||
SIMDJSON_WARN_UNUSED simdjson_really_inline bool copy_to_buffer(const uint8_t *json, uint8_t (&buf)[N]) noexcept;
|
||||
|
||||
simdjson_really_inline json_iterator_ref borrow() noexcept;
|
||||
|
||||
|
|
|
@ -44,4 +44,17 @@ simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::raw_js
|
|||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string>::simdjson_result(error_code error) noexcept
|
||||
: implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string>(error) {}
|
||||
|
||||
simdjson_really_inline simdjson_result<const char *> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string>::raw() const noexcept {
|
||||
if (error()) { return error(); }
|
||||
return first.raw();
|
||||
}
|
||||
simdjson_really_inline SIMDJSON_WARN_UNUSED simdjson_result<std::string_view> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string>::unescape(uint8_t *&dst) const noexcept {
|
||||
if (error()) { return error(); }
|
||||
return first.unescape(dst);
|
||||
}
|
||||
simdjson_really_inline SIMDJSON_WARN_UNUSED simdjson_result<std::string_view> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string>::unescape(SIMDJSON_IMPLEMENTATION::ondemand::json_iterator &iter) const noexcept {
|
||||
if (error()) { return error(); }
|
||||
return first.unescape(iter);
|
||||
}
|
||||
|
||||
} // namespace simdjson
|
||||
|
|
|
@ -87,6 +87,10 @@ public:
|
|||
simdjson_really_inline simdjson_result() noexcept = default;
|
||||
simdjson_really_inline simdjson_result(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string> &a) noexcept = default;
|
||||
simdjson_really_inline ~simdjson_result() noexcept = default; ///< @private
|
||||
|
||||
simdjson_really_inline simdjson_result<const char *> raw() const noexcept;
|
||||
simdjson_really_inline SIMDJSON_WARN_UNUSED simdjson_result<std::string_view> unescape(uint8_t *&dst) const noexcept;
|
||||
simdjson_really_inline SIMDJSON_WARN_UNUSED simdjson_result<std::string_view> unescape(SIMDJSON_IMPLEMENTATION::ondemand::json_iterator &iter) const noexcept;
|
||||
};
|
||||
|
||||
} // namespace simdjson
|
||||
|
|
|
@ -30,110 +30,74 @@ simdjson_really_inline value value::start(json_iterator_ref &&iter) noexcept {
|
|||
return { std::forward<json_iterator_ref>(iter), iter->advance() };
|
||||
}
|
||||
|
||||
simdjson_really_inline simdjson_result<array> value::get_array() && noexcept {
|
||||
if (*json != '[') {
|
||||
log_error("not an array");
|
||||
iter.release(); // Communicate that we have handled the value PERF TODO elided, right?
|
||||
return INCORRECT_TYPE;
|
||||
}
|
||||
return array::started(std::forward<json_iterator_ref>(iter));
|
||||
simdjson_really_inline void value::consume() noexcept {
|
||||
iter.release();
|
||||
}
|
||||
simdjson_really_inline simdjson_result<object> value::get_object() && noexcept {
|
||||
if (*json != '{') {
|
||||
log_error("not an object");
|
||||
iter.release(); // Communicate that we have handled the value PERF TODO elided, right?
|
||||
return INCORRECT_TYPE;
|
||||
}
|
||||
return object::started(std::forward<json_iterator_ref>(iter));
|
||||
template<typename T>
|
||||
simdjson_really_inline simdjson_result<T> value::consume_if_success(simdjson_result<T> &&result) noexcept {
|
||||
if (!result.error()) { consume(); }
|
||||
return std::forward<simdjson_result<T>>(result);
|
||||
}
|
||||
simdjson_really_inline simdjson_result<raw_json_string> value::get_raw_json_string() && noexcept {
|
||||
log_value("string");
|
||||
iter.release(); // Communicate that we have handled the value PERF TODO elided, right?
|
||||
if (*json != '"') { log_error("not a string"); return INCORRECT_TYPE; }
|
||||
return raw_json_string{&json[1]};
|
||||
|
||||
simdjson_really_inline simdjson_result<array> value::get_array() noexcept {
|
||||
bool is_empty;
|
||||
SIMDJSON_TRY( iter->start_array(json).get(is_empty) );
|
||||
if (is_empty) { iter.release(); }
|
||||
return array(std::move(iter));
|
||||
}
|
||||
simdjson_really_inline simdjson_result<std::string_view> value::get_string() && noexcept {
|
||||
log_value("string");
|
||||
if (*json != '"') {
|
||||
log_error("not a string");
|
||||
iter.release(); // Communicate that we have handled the value PERF TODO elided, right?
|
||||
return INCORRECT_TYPE;
|
||||
}
|
||||
auto result = raw_json_string{&json[1]}.unescape(iter->current_string_buf_loc);
|
||||
iter.release(); // Communicate that we have handled the value PERF TODO elided, right?
|
||||
return result;
|
||||
simdjson_really_inline simdjson_result<object> value::get_object() noexcept {
|
||||
bool is_empty;
|
||||
SIMDJSON_TRY( iter->start_object(json).get(is_empty) );
|
||||
if (is_empty) { iter.release(); }
|
||||
return object(std::move(iter));
|
||||
}
|
||||
simdjson_really_inline simdjson_result<double> value::get_double() && noexcept {
|
||||
log_value("double");
|
||||
iter.release(); // Communicate that we have handled the value PERF TODO elided, right?
|
||||
double result;
|
||||
error_code error;
|
||||
if ((error = numberparsing::parse_double(json).get(result))) { log_error("not a double"); return error; }
|
||||
return result;
|
||||
simdjson_really_inline simdjson_result<raw_json_string> value::get_raw_json_string() noexcept {
|
||||
return consume_if_success( iter->parse_raw_json_string(json) );
|
||||
}
|
||||
simdjson_really_inline simdjson_result<uint64_t> value::get_uint64() && noexcept {
|
||||
log_value("unsigned");
|
||||
iter.release(); // Communicate that we have handled the value PERF TODO elided, right?
|
||||
uint64_t result;
|
||||
error_code error;
|
||||
if ((error = numberparsing::parse_unsigned(json).get(result))) { log_error("not a unsigned integer"); return error; }
|
||||
return result;
|
||||
simdjson_really_inline simdjson_result<std::string_view> value::get_string() noexcept {
|
||||
return consume_if_success( iter->parse_string(json) );
|
||||
}
|
||||
simdjson_really_inline simdjson_result<int64_t> value::get_int64() && noexcept {
|
||||
log_value("integer");
|
||||
iter.release(); // Communicate that we have handled the value PERF TODO elided, right?
|
||||
int64_t result;
|
||||
error_code error;
|
||||
if ((error = numberparsing::parse_integer(json).get(result))) { log_error("not an integer"); return error; }
|
||||
return result;
|
||||
simdjson_really_inline simdjson_result<double> value::get_double() noexcept {
|
||||
return consume_if_success( iter->parse_double(json) );
|
||||
}
|
||||
simdjson_really_inline simdjson_result<bool> value::get_bool() && noexcept {
|
||||
log_value("bool");
|
||||
iter.release(); // Communicate that we have handled the value PERF TODO elided, right?
|
||||
auto not_true = atomparsing::str4ncmp(json, "true");
|
||||
auto not_false = atomparsing::str4ncmp(json, "fals") | (json[4] ^ 'e');
|
||||
bool error = (not_true && not_false) || jsoncharutils::is_not_structural_or_whitespace(json[not_true ? 5 : 4]);
|
||||
if (error) { log_error("not a boolean"); return INCORRECT_TYPE; }
|
||||
return simdjson_result<bool>(!not_true, error ? INCORRECT_TYPE : SUCCESS);
|
||||
simdjson_really_inline simdjson_result<uint64_t> value::get_uint64() noexcept {
|
||||
return consume_if_success( iter->parse_uint64(json) );
|
||||
}
|
||||
simdjson_really_inline bool value::is_null() & noexcept {
|
||||
log_value("null");
|
||||
// Since it's a *reference*, we may want to check something other than is_null() if it isn't null,
|
||||
// so we don't release the iterator unless it is actually null
|
||||
if (atomparsing::str4ncmp(json, "null")) { return false; }
|
||||
iter.release(); // Communicate that we have handled the value PERF TODO elided, right?
|
||||
return true;
|
||||
simdjson_really_inline simdjson_result<int64_t> value::get_int64() noexcept {
|
||||
return consume_if_success( iter->parse_int64(json) );
|
||||
}
|
||||
simdjson_really_inline bool value::is_null() && noexcept {
|
||||
log_value("null");
|
||||
iter.release(); // Communicate that we have handled the value PERF TODO elided, right?
|
||||
if (atomparsing::str4ncmp(json, "null")) { return false; }
|
||||
simdjson_really_inline simdjson_result<bool> value::get_bool() noexcept {
|
||||
return consume_if_success( iter->parse_bool(json) );
|
||||
}
|
||||
simdjson_really_inline bool value::is_null() noexcept {
|
||||
if (!iter->is_null(json)) { return false; }
|
||||
consume();
|
||||
return true;
|
||||
}
|
||||
|
||||
#if SIMDJSON_EXCEPTIONS
|
||||
simdjson_really_inline value::operator array() && noexcept(false) {
|
||||
simdjson_really_inline value::operator array() noexcept(false) {
|
||||
return std::forward<value>(*this).get_array();
|
||||
}
|
||||
simdjson_really_inline value::operator object() && noexcept(false) {
|
||||
simdjson_really_inline value::operator object() noexcept(false) {
|
||||
return std::forward<value>(*this).get_object();
|
||||
}
|
||||
simdjson_really_inline value::operator uint64_t() && noexcept(false) {
|
||||
simdjson_really_inline value::operator uint64_t() noexcept(false) {
|
||||
return std::forward<value>(*this).get_uint64();
|
||||
}
|
||||
simdjson_really_inline value::operator int64_t() && noexcept(false) {
|
||||
simdjson_really_inline value::operator int64_t() noexcept(false) {
|
||||
return std::forward<value>(*this).get_int64();
|
||||
}
|
||||
simdjson_really_inline value::operator double() && noexcept(false) {
|
||||
simdjson_really_inline value::operator double() noexcept(false) {
|
||||
return std::forward<value>(*this).get_double();
|
||||
}
|
||||
simdjson_really_inline value::operator std::string_view() && noexcept(false) {
|
||||
simdjson_really_inline value::operator std::string_view() noexcept(false) {
|
||||
return std::forward<value>(*this).get_string();
|
||||
}
|
||||
simdjson_really_inline value::operator raw_json_string() && noexcept(false) {
|
||||
simdjson_really_inline value::operator raw_json_string() noexcept(false) {
|
||||
return std::forward<value>(*this).get_raw_json_string();
|
||||
}
|
||||
simdjson_really_inline value::operator bool() && noexcept(false) {
|
||||
simdjson_really_inline value::operator bool() noexcept(false) {
|
||||
return std::forward<value>(*this).get_bool();
|
||||
}
|
||||
#endif
|
||||
|
@ -219,77 +183,73 @@ simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>
|
|||
return std::forward<SIMDJSON_IMPLEMENTATION::ondemand::value>(first)[key];
|
||||
}
|
||||
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get_array() && noexcept {
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get_array() noexcept {
|
||||
if (error()) { return error(); }
|
||||
return std::forward<SIMDJSON_IMPLEMENTATION::ondemand::value>(first).get_array();
|
||||
}
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get_object() && noexcept {
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get_object() noexcept {
|
||||
if (error()) { return error(); }
|
||||
return std::forward<SIMDJSON_IMPLEMENTATION::ondemand::value>(first).get_object();
|
||||
}
|
||||
simdjson_really_inline simdjson_result<uint64_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get_uint64() && noexcept {
|
||||
simdjson_really_inline simdjson_result<uint64_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get_uint64() noexcept {
|
||||
if (error()) { return error(); }
|
||||
return std::forward<SIMDJSON_IMPLEMENTATION::ondemand::value>(first).get_uint64();
|
||||
}
|
||||
simdjson_really_inline simdjson_result<int64_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get_int64() && noexcept {
|
||||
simdjson_really_inline simdjson_result<int64_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get_int64() noexcept {
|
||||
if (error()) { return error(); }
|
||||
return std::forward<SIMDJSON_IMPLEMENTATION::ondemand::value>(first).get_int64();
|
||||
}
|
||||
simdjson_really_inline simdjson_result<double> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get_double() && noexcept {
|
||||
simdjson_really_inline simdjson_result<double> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get_double() noexcept {
|
||||
if (error()) { return error(); }
|
||||
return std::forward<SIMDJSON_IMPLEMENTATION::ondemand::value>(first).get_double();
|
||||
}
|
||||
simdjson_really_inline simdjson_result<std::string_view> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get_string() && noexcept {
|
||||
simdjson_really_inline simdjson_result<std::string_view> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get_string() noexcept {
|
||||
if (error()) { return error(); }
|
||||
return std::forward<SIMDJSON_IMPLEMENTATION::ondemand::value>(first).get_string();
|
||||
}
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get_raw_json_string() && noexcept {
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get_raw_json_string() noexcept {
|
||||
if (error()) { return error(); }
|
||||
return std::forward<SIMDJSON_IMPLEMENTATION::ondemand::value>(first).get_raw_json_string();
|
||||
}
|
||||
simdjson_really_inline simdjson_result<bool> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get_bool() && noexcept {
|
||||
simdjson_really_inline simdjson_result<bool> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get_bool() noexcept {
|
||||
if (error()) { return error(); }
|
||||
return std::forward<SIMDJSON_IMPLEMENTATION::ondemand::value>(first).get_bool();
|
||||
}
|
||||
simdjson_really_inline bool simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::is_null() & noexcept {
|
||||
simdjson_really_inline bool simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::is_null() noexcept {
|
||||
if (error()) { return false; }
|
||||
return first.is_null();
|
||||
}
|
||||
simdjson_really_inline bool simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::is_null() && noexcept {
|
||||
if (error()) { return false; }
|
||||
return std::forward<SIMDJSON_IMPLEMENTATION::ondemand::value>(first).is_null();
|
||||
}
|
||||
|
||||
#if SIMDJSON_EXCEPTIONS
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::operator SIMDJSON_IMPLEMENTATION::ondemand::array() && noexcept(false) {
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::operator SIMDJSON_IMPLEMENTATION::ondemand::array() noexcept(false) {
|
||||
if (error()) { throw simdjson_error(error()); }
|
||||
return std::forward<SIMDJSON_IMPLEMENTATION::ondemand::value>(first);
|
||||
}
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::operator SIMDJSON_IMPLEMENTATION::ondemand::object() && noexcept(false) {
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::operator SIMDJSON_IMPLEMENTATION::ondemand::object() noexcept(false) {
|
||||
if (error()) { throw simdjson_error(error()); }
|
||||
return std::forward<SIMDJSON_IMPLEMENTATION::ondemand::value>(first);
|
||||
}
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::operator uint64_t() && noexcept(false) {
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::operator uint64_t() noexcept(false) {
|
||||
if (error()) { throw simdjson_error(error()); }
|
||||
return std::forward<SIMDJSON_IMPLEMENTATION::ondemand::value>(first);
|
||||
}
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::operator int64_t() && noexcept(false) {
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::operator int64_t() noexcept(false) {
|
||||
if (error()) { throw simdjson_error(error()); }
|
||||
return std::forward<SIMDJSON_IMPLEMENTATION::ondemand::value>(first);
|
||||
}
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::operator double() && noexcept(false) {
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::operator double() noexcept(false) {
|
||||
if (error()) { throw simdjson_error(error()); }
|
||||
return std::forward<SIMDJSON_IMPLEMENTATION::ondemand::value>(first);
|
||||
}
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::operator std::string_view() && noexcept(false) {
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::operator std::string_view() noexcept(false) {
|
||||
if (error()) { throw simdjson_error(error()); }
|
||||
return std::forward<SIMDJSON_IMPLEMENTATION::ondemand::value>(first);
|
||||
}
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::operator SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string() && noexcept(false) {
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::operator SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string() noexcept(false) {
|
||||
if (error()) { throw simdjson_error(error()); }
|
||||
return std::forward<SIMDJSON_IMPLEMENTATION::ondemand::value>(first);
|
||||
}
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::operator bool() && noexcept(false) {
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::operator bool() noexcept(false) {
|
||||
if (error()) { throw simdjson_error(error()); }
|
||||
return std::forward<SIMDJSON_IMPLEMENTATION::ondemand::value>(first);
|
||||
}
|
||||
|
|
|
@ -38,35 +38,35 @@ public:
|
|||
* @returns An object that can be used to iterate the array.
|
||||
* @returns INCORRECT_TYPE If the JSON value is not an array.
|
||||
*/
|
||||
simdjson_really_inline simdjson_result<array> get_array() && noexcept;
|
||||
simdjson_really_inline simdjson_result<array> get_array() noexcept;
|
||||
/**
|
||||
* Cast this JSON value to an object.
|
||||
*
|
||||
* @returns An object that can be used to look up or iterate fields.
|
||||
* @returns INCORRECT_TYPE If the JSON value is not an object.
|
||||
*/
|
||||
simdjson_really_inline simdjson_result<object> get_object() && noexcept;
|
||||
simdjson_really_inline simdjson_result<object> get_object() noexcept;
|
||||
/**
|
||||
* Cast this JSON value to an unsigned integer.
|
||||
*
|
||||
* @returns A signed 64-bit integer.
|
||||
* @returns INCORRECT_TYPE If the JSON value is not a 64-bit unsigned integer.
|
||||
*/
|
||||
simdjson_really_inline simdjson_result<uint64_t> get_uint64() && noexcept;
|
||||
simdjson_really_inline simdjson_result<uint64_t> get_uint64() noexcept;
|
||||
/**
|
||||
* Cast this JSON value to a signed integer.
|
||||
*
|
||||
* @returns A signed 64-bit integer.
|
||||
* @returns INCORRECT_TYPE If the JSON value is not a 64-bit integer.
|
||||
*/
|
||||
simdjson_really_inline simdjson_result<int64_t> get_int64() && noexcept;
|
||||
simdjson_really_inline simdjson_result<int64_t> get_int64() noexcept;
|
||||
/**
|
||||
* Cast this JSON value to a double.
|
||||
*
|
||||
* @returns A double.
|
||||
* @returns INCORRECT_TYPE If the JSON value is not a valid floating-point number.
|
||||
*/
|
||||
simdjson_really_inline simdjson_result<double> get_double() && noexcept;
|
||||
simdjson_really_inline simdjson_result<double> get_double() noexcept;
|
||||
/**
|
||||
* Cast this JSON value to a string.
|
||||
*
|
||||
|
@ -78,7 +78,7 @@ public:
|
|||
* time it parses a document or when it is destroyed.
|
||||
* @returns INCORRECT_TYPE if the JSON value is not a string.
|
||||
*/
|
||||
simdjson_really_inline simdjson_result<std::string_view> get_string() && noexcept;
|
||||
simdjson_really_inline simdjson_result<std::string_view> get_string() noexcept;
|
||||
/**
|
||||
* Cast this JSON value to a raw_json_string.
|
||||
*
|
||||
|
@ -87,24 +87,20 @@ public:
|
|||
* @returns A pointer to the raw JSON for the given string.
|
||||
* @returns INCORRECT_TYPE if the JSON value is not a string.
|
||||
*/
|
||||
simdjson_really_inline simdjson_result<raw_json_string> get_raw_json_string() && noexcept;
|
||||
simdjson_really_inline simdjson_result<raw_json_string> get_raw_json_string() noexcept;
|
||||
/**
|
||||
* Cast this JSON value to a bool.
|
||||
*
|
||||
* @returns A bool value.
|
||||
* @returns INCORRECT_TYPE if the JSON value is not true or false.
|
||||
*/
|
||||
simdjson_really_inline simdjson_result<bool> get_bool() && noexcept;
|
||||
simdjson_really_inline simdjson_result<bool> get_bool() noexcept;
|
||||
/**
|
||||
* Checks if this JSON value is null.
|
||||
*
|
||||
* @returns Whether the value is null.
|
||||
*/
|
||||
simdjson_really_inline bool is_null() & noexcept;
|
||||
/**
|
||||
* @overload bool is_null() & noexcept
|
||||
*/
|
||||
simdjson_really_inline bool is_null() && noexcept;
|
||||
simdjson_really_inline bool is_null() noexcept;
|
||||
|
||||
#if SIMDJSON_EXCEPTIONS
|
||||
/**
|
||||
|
@ -113,35 +109,35 @@ public:
|
|||
* @returns An object that can be used to iterate the array.
|
||||
* @exception simdjson_error(INCORRECT_TYPE) If the JSON value is not an array.
|
||||
*/
|
||||
simdjson_really_inline operator array() && noexcept(false);
|
||||
simdjson_really_inline operator array() noexcept(false);
|
||||
/**
|
||||
* Cast this JSON value to an object.
|
||||
*
|
||||
* @returns An object that can be used to look up or iterate fields.
|
||||
* @exception simdjson_error(INCORRECT_TYPE) If the JSON value is not an object.
|
||||
*/
|
||||
simdjson_really_inline operator object() && noexcept(false);
|
||||
simdjson_really_inline operator object() noexcept(false);
|
||||
/**
|
||||
* Cast this JSON value to an unsigned integer.
|
||||
*
|
||||
* @returns A signed 64-bit integer.
|
||||
* @exception simdjson_error(INCORRECT_TYPE) If the JSON value is not a 64-bit unsigned integer.
|
||||
*/
|
||||
simdjson_really_inline operator uint64_t() && noexcept(false);
|
||||
simdjson_really_inline operator uint64_t() noexcept(false);
|
||||
/**
|
||||
* Cast this JSON value to a signed integer.
|
||||
*
|
||||
* @returns A signed 64-bit integer.
|
||||
* @exception simdjson_error(INCORRECT_TYPE) If the JSON value is not a 64-bit integer.
|
||||
*/
|
||||
simdjson_really_inline operator int64_t() && noexcept(false);
|
||||
simdjson_really_inline operator int64_t() noexcept(false);
|
||||
/**
|
||||
* Cast this JSON value to a double.
|
||||
*
|
||||
* @returns A double.
|
||||
* @exception simdjson_error(INCORRECT_TYPE) If the JSON value is not a valid floating-point number.
|
||||
*/
|
||||
simdjson_really_inline operator double() && noexcept(false);
|
||||
simdjson_really_inline operator double() noexcept(false);
|
||||
/**
|
||||
* Cast this JSON value to a string.
|
||||
*
|
||||
|
@ -153,7 +149,7 @@ public:
|
|||
* time it parses a document or when it is destroyed.
|
||||
* @exception simdjson_error(INCORRECT_TYPE) if the JSON value is not a string.
|
||||
*/
|
||||
simdjson_really_inline operator std::string_view() && noexcept(false);
|
||||
simdjson_really_inline operator std::string_view() noexcept(false);
|
||||
/**
|
||||
* Cast this JSON value to a raw_json_string.
|
||||
*
|
||||
|
@ -162,14 +158,14 @@ public:
|
|||
* @returns A pointer to the raw JSON for the given string.
|
||||
* @exception simdjson_error(INCORRECT_TYPE) if the JSON value is not a string.
|
||||
*/
|
||||
simdjson_really_inline operator raw_json_string() && noexcept(false);
|
||||
simdjson_really_inline operator raw_json_string() noexcept(false);
|
||||
/**
|
||||
* Cast this JSON value to a bool.
|
||||
*
|
||||
* @returns A bool value.
|
||||
* @exception simdjson_error(INCORRECT_TYPE) if the JSON value is not true or false.
|
||||
*/
|
||||
simdjson_really_inline operator bool() && noexcept(false);
|
||||
simdjson_really_inline operator bool() noexcept(false);
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -239,6 +235,9 @@ protected:
|
|||
simdjson_really_inline json_iterator_ref borrow_iterator() noexcept;
|
||||
simdjson_really_inline bool is_iteration_finished() const noexcept;
|
||||
simdjson_really_inline void iteration_finished() noexcept;
|
||||
simdjson_really_inline void consume() noexcept;
|
||||
template<typename T>
|
||||
simdjson_really_inline simdjson_result<T> consume_if_success(simdjson_result<T> &&result) noexcept;
|
||||
|
||||
json_iterator_ref iter{};
|
||||
const uint8_t *json{}; // The JSON text of the value
|
||||
|
@ -268,26 +267,25 @@ public:
|
|||
simdjson_really_inline simdjson_result(simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> &&a) noexcept = default;
|
||||
simdjson_really_inline ~simdjson_result() noexcept = default; ///< @private
|
||||
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array> get_array() && noexcept;
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object> get_object() && noexcept;
|
||||
simdjson_really_inline simdjson_result<uint64_t> get_uint64() && noexcept;
|
||||
simdjson_really_inline simdjson_result<int64_t> get_int64() && noexcept;
|
||||
simdjson_really_inline simdjson_result<double> get_double() && noexcept;
|
||||
simdjson_really_inline simdjson_result<std::string_view> get_string() && noexcept;
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string> get_raw_json_string() && noexcept;
|
||||
simdjson_really_inline simdjson_result<bool> get_bool() && noexcept;
|
||||
simdjson_really_inline bool is_null() & noexcept;
|
||||
simdjson_really_inline bool is_null() && noexcept;
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array> get_array() noexcept;
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object> get_object() noexcept;
|
||||
simdjson_really_inline simdjson_result<uint64_t> get_uint64() noexcept;
|
||||
simdjson_really_inline simdjson_result<int64_t> get_int64() noexcept;
|
||||
simdjson_really_inline simdjson_result<double> get_double() noexcept;
|
||||
simdjson_really_inline simdjson_result<std::string_view> get_string() noexcept;
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string> get_raw_json_string() noexcept;
|
||||
simdjson_really_inline simdjson_result<bool> get_bool() noexcept;
|
||||
simdjson_really_inline bool is_null() noexcept;
|
||||
|
||||
#if SIMDJSON_EXCEPTIONS
|
||||
simdjson_really_inline operator SIMDJSON_IMPLEMENTATION::ondemand::array() && noexcept(false);
|
||||
simdjson_really_inline operator SIMDJSON_IMPLEMENTATION::ondemand::object() && noexcept(false);
|
||||
simdjson_really_inline operator uint64_t() && noexcept(false);
|
||||
simdjson_really_inline operator int64_t() && noexcept(false);
|
||||
simdjson_really_inline operator double() && noexcept(false);
|
||||
simdjson_really_inline operator std::string_view() && noexcept(false);
|
||||
simdjson_really_inline operator SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string() && noexcept(false);
|
||||
simdjson_really_inline operator bool() && noexcept(false);
|
||||
simdjson_really_inline operator SIMDJSON_IMPLEMENTATION::ondemand::array() noexcept(false);
|
||||
simdjson_really_inline operator SIMDJSON_IMPLEMENTATION::ondemand::object() noexcept(false);
|
||||
simdjson_really_inline operator uint64_t() noexcept(false);
|
||||
simdjson_really_inline operator int64_t() noexcept(false);
|
||||
simdjson_really_inline operator double() noexcept(false);
|
||||
simdjson_really_inline operator std::string_view() noexcept(false);
|
||||
simdjson_really_inline operator SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string() noexcept(false);
|
||||
simdjson_really_inline operator bool() noexcept(false);
|
||||
#endif
|
||||
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator<SIMDJSON_IMPLEMENTATION::ondemand::value>> begin() & noexcept;
|
||||
|
|
Loading…
Reference in New Issue