Add get_X and is_X methods
This commit is contained in:
parent
efc168f473
commit
0b8c357eff
|
@ -43,8 +43,135 @@ public:
|
|||
/** The type of this element. */
|
||||
really_inline element_type type() const noexcept;
|
||||
|
||||
/** Whether this element is a json `null`. */
|
||||
really_inline bool is_null() const noexcept;
|
||||
/**
|
||||
* Cast this element to an array.
|
||||
*
|
||||
* Equivalent to get<array>().
|
||||
*
|
||||
* @returns An object that can be used to iterate the array, or:
|
||||
* INCORRECT_TYPE if the JSON element is not an array.
|
||||
*/
|
||||
inline simdjson_result<array> get_array() const noexcept;
|
||||
/**
|
||||
* Cast this element to an object.
|
||||
*
|
||||
* Equivalent to get<object>().
|
||||
*
|
||||
* @returns An object that can be used to look up or iterate the object's fields, or:
|
||||
* INCORRECT_TYPE if the JSON element is not an object.
|
||||
*/
|
||||
inline simdjson_result<object> get_object() const noexcept;
|
||||
/**
|
||||
* Cast this element to a string.
|
||||
*
|
||||
* Equivalent to get<const char *>().
|
||||
*
|
||||
* @returns An pointer to a null-terminated string. This string is stored in the parser and will
|
||||
* be invalidated the next time it parses a document or when it is destroyed.
|
||||
* Returns INCORRECT_TYPE if the JSON element is not a string.
|
||||
*/
|
||||
inline simdjson_result<const char *> get_c_str() const noexcept;
|
||||
/**
|
||||
* Cast this element to a string.
|
||||
*
|
||||
* Equivalent to get<std::string_view>().
|
||||
*
|
||||
* @returns A string. The string is stored in the parser and will be invalidated the next time it
|
||||
* parses a document or when it is destroyed.
|
||||
* Returns INCORRECT_TYPE if the JSON element is not a string.
|
||||
*/
|
||||
inline simdjson_result<std::string_view> get_string() const noexcept;
|
||||
/**
|
||||
* Cast this element to a signed integer.
|
||||
*
|
||||
* Equivalent to get<int64_t>().
|
||||
*
|
||||
* @returns A signed 64-bit integer.
|
||||
* Returns INCORRECT_TYPE if the JSON element is not an integer, or NUMBER_OUT_OF_RANGE
|
||||
* if it is negative.
|
||||
*/
|
||||
inline simdjson_result<int64_t> get_int64_t() const noexcept;
|
||||
/**
|
||||
* Cast this element to an unsigned integer.
|
||||
*
|
||||
* Equivalent to get<uint64_t>().
|
||||
*
|
||||
* @returns An unsigned 64-bit integer.
|
||||
* Returns INCORRECT_TYPE if the JSON element is not an integer, or NUMBER_OUT_OF_RANGE
|
||||
* if it is too large.
|
||||
*/
|
||||
inline simdjson_result<uint64_t> get_uint64_t() const noexcept;
|
||||
/**
|
||||
* Cast this element to an double floating-point.
|
||||
*
|
||||
* Equivalent to get<double>().
|
||||
*
|
||||
* @returns A double value.
|
||||
* Returns INCORRECT_TYPE if the JSON element is not a number.
|
||||
*/
|
||||
inline simdjson_result<double> get_double() const noexcept;
|
||||
/**
|
||||
* Cast this element to a bool.
|
||||
*
|
||||
* Equivalent to get<bool>().
|
||||
*
|
||||
* @returns A bool value.
|
||||
* Returns INCORRECT_TYPE if the JSON element is not a boolean.
|
||||
*/
|
||||
inline simdjson_result<bool> get_bool() const noexcept;
|
||||
|
||||
/**
|
||||
* Whether this element is a json array.
|
||||
*
|
||||
* Equivalent to is<array>().
|
||||
*/
|
||||
inline bool is_array() const noexcept;
|
||||
/**
|
||||
* Whether this element is a json object.
|
||||
*
|
||||
* Equivalent to is<object>().
|
||||
*/
|
||||
inline bool is_object() const noexcept;
|
||||
/**
|
||||
* Whether this element is a json string.
|
||||
*
|
||||
* Equivalent to is<std::string_view>() or is<const char *>().
|
||||
*/
|
||||
inline bool is_string() const noexcept;
|
||||
/**
|
||||
* Whether this element is a json number that fits in a signed 64-bit integer.
|
||||
*
|
||||
* Equivalent to is<int64_t>().
|
||||
*/
|
||||
inline bool is_int64_t() const noexcept;
|
||||
/**
|
||||
* Whether this element is a json number that fits in an unsigned 64-bit integer.
|
||||
*
|
||||
* Equivalent to is<uint64_t>().
|
||||
*/
|
||||
inline bool is_uint64_t() const noexcept;
|
||||
/**
|
||||
* Whether this element is a json number that fits in a double.
|
||||
*
|
||||
* Equivalent to is<double>().
|
||||
*/
|
||||
inline bool is_double() const noexcept;
|
||||
/**
|
||||
* Whether this element is a json number.
|
||||
*
|
||||
* Both integers and floating points will return true.
|
||||
*/
|
||||
inline bool is_number() const noexcept;
|
||||
/**
|
||||
* Whether this element is a json `true` or `false`.
|
||||
*
|
||||
* Equivalent to is<bool>().
|
||||
*/
|
||||
inline bool is_bool() const noexcept;
|
||||
/**
|
||||
* Whether this element is a json `null`.
|
||||
*/
|
||||
inline bool is_null() const noexcept;
|
||||
|
||||
/**
|
||||
* Tell whether the value can be cast to provided type (T).
|
||||
|
@ -290,12 +417,29 @@ public:
|
|||
really_inline simdjson_result(error_code error) noexcept; ///< @private
|
||||
|
||||
inline simdjson_result<dom::element_type> type() const noexcept;
|
||||
inline simdjson_result<bool> is_null() const noexcept;
|
||||
template<typename T>
|
||||
inline simdjson_result<bool> is() const noexcept;
|
||||
template<typename T>
|
||||
inline simdjson_result<T> get() const noexcept;
|
||||
|
||||
inline simdjson_result<dom::array> get_array() const noexcept;
|
||||
inline simdjson_result<dom::object> get_object() const noexcept;
|
||||
inline simdjson_result<const char *> get_c_str() const noexcept;
|
||||
inline simdjson_result<std::string_view> get_string() const noexcept;
|
||||
inline simdjson_result<int64_t> get_int64_t() const noexcept;
|
||||
inline simdjson_result<uint64_t> get_uint64_t() const noexcept;
|
||||
inline simdjson_result<double> get_double() const noexcept;
|
||||
inline simdjson_result<bool> get_bool() const noexcept;
|
||||
|
||||
inline simdjson_result<bool> is_array() const noexcept;
|
||||
inline simdjson_result<bool> is_object() const noexcept;
|
||||
inline simdjson_result<bool> is_string() const noexcept;
|
||||
inline simdjson_result<bool> is_int64_t() const noexcept;
|
||||
inline simdjson_result<bool> is_uint64_t() const noexcept;
|
||||
inline simdjson_result<bool> is_double() const noexcept;
|
||||
inline simdjson_result<bool> is_bool() const noexcept;
|
||||
inline simdjson_result<bool> is_null() const noexcept;
|
||||
|
||||
inline simdjson_result<dom::element> operator[](const std::string_view &key) const noexcept;
|
||||
inline simdjson_result<dom::element> operator[](const char *key) const noexcept;
|
||||
inline simdjson_result<dom::element> at(const std::string_view &json_pointer) const noexcept;
|
||||
|
|
|
@ -22,10 +22,7 @@ inline simdjson_result<dom::element_type> simdjson_result<dom::element>::type()
|
|||
if (error()) { return error(); }
|
||||
return first.type();
|
||||
}
|
||||
inline simdjson_result<bool> simdjson_result<dom::element>::is_null() const noexcept {
|
||||
if (error()) { return error(); }
|
||||
return first.is_null();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline simdjson_result<bool> simdjson_result<dom::element>::is() const noexcept {
|
||||
if (error()) { return error(); }
|
||||
|
@ -37,6 +34,73 @@ inline simdjson_result<T> simdjson_result<dom::element>::get() const noexcept {
|
|||
return first.get<T>();
|
||||
}
|
||||
|
||||
inline simdjson_result<dom::array> simdjson_result<dom::element>::get_array() const noexcept {
|
||||
if (error()) { return error(); }
|
||||
return first.get_array();
|
||||
}
|
||||
inline simdjson_result<dom::object> simdjson_result<dom::element>::get_object() const noexcept {
|
||||
if (error()) { return error(); }
|
||||
return first.get_object();
|
||||
}
|
||||
inline simdjson_result<const char *> simdjson_result<dom::element>::get_c_str() const noexcept {
|
||||
if (error()) { return error(); }
|
||||
return first.get_c_str();
|
||||
}
|
||||
inline simdjson_result<std::string_view> simdjson_result<dom::element>::get_string() const noexcept {
|
||||
if (error()) { return error(); }
|
||||
return first.get_string();
|
||||
}
|
||||
inline simdjson_result<int64_t> simdjson_result<dom::element>::get_int64_t() const noexcept {
|
||||
if (error()) { return error(); }
|
||||
return first.get_int64_t();
|
||||
}
|
||||
inline simdjson_result<uint64_t> simdjson_result<dom::element>::get_uint64_t() const noexcept {
|
||||
if (error()) { return error(); }
|
||||
return first.get_uint64_t();
|
||||
}
|
||||
inline simdjson_result<double> simdjson_result<dom::element>::get_double() const noexcept {
|
||||
if (error()) { return error(); }
|
||||
return first.get_double();
|
||||
}
|
||||
inline simdjson_result<bool> simdjson_result<dom::element>::get_bool() const noexcept {
|
||||
if (error()) { return error(); }
|
||||
return first.get_bool();
|
||||
}
|
||||
|
||||
inline simdjson_result<bool> simdjson_result<dom::element>::is_array() const noexcept {
|
||||
if (error()) { return error(); }
|
||||
return first.is_array();
|
||||
}
|
||||
inline simdjson_result<bool> simdjson_result<dom::element>::is_object() const noexcept {
|
||||
if (error()) { return error(); }
|
||||
return first.is_object();
|
||||
}
|
||||
inline simdjson_result<bool> simdjson_result<dom::element>::is_string() const noexcept {
|
||||
if (error()) { return error(); }
|
||||
return first.is_string();
|
||||
}
|
||||
inline simdjson_result<bool> simdjson_result<dom::element>::is_int64_t() const noexcept {
|
||||
if (error()) { return error(); }
|
||||
return first.is_int64_t();
|
||||
}
|
||||
inline simdjson_result<bool> simdjson_result<dom::element>::is_uint64_t() const noexcept {
|
||||
if (error()) { return error(); }
|
||||
return first.is_uint64_t();
|
||||
}
|
||||
inline simdjson_result<bool> simdjson_result<dom::element>::is_double() const noexcept {
|
||||
if (error()) { return error(); }
|
||||
return first.is_double();
|
||||
}
|
||||
inline simdjson_result<bool> simdjson_result<dom::element>::is_bool() const noexcept {
|
||||
if (error()) { return error(); }
|
||||
return first.is_bool();
|
||||
}
|
||||
|
||||
inline simdjson_result<bool> simdjson_result<dom::element>::is_null() const noexcept {
|
||||
if (error()) { return error(); }
|
||||
return first.is_null();
|
||||
}
|
||||
|
||||
inline simdjson_result<dom::element> simdjson_result<dom::element>::operator[](const std::string_view &key) const noexcept {
|
||||
if (error()) { return error(); }
|
||||
return first[key];
|
||||
|
@ -112,9 +176,6 @@ inline element_type element::type() const noexcept {
|
|||
auto tape_type = tape.tape_ref_type();
|
||||
return tape_type == internal::tape_type::FALSE_VALUE ? element_type::BOOL : static_cast<element_type>(tape_type);
|
||||
}
|
||||
really_inline bool element::is_null() const noexcept {
|
||||
return tape.is_null_on_tape();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline simdjson_result<bool> element::get<bool>() const noexcept {
|
||||
|
@ -215,11 +276,32 @@ inline simdjson_result<object> element::get<object>() const noexcept {
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
really_inline bool element::is() const noexcept {
|
||||
inline bool element::is() const noexcept {
|
||||
auto result = get<T>();
|
||||
return !result.error();
|
||||
}
|
||||
|
||||
inline simdjson_result<array> element::get_array() const noexcept { return get<array>(); }
|
||||
inline simdjson_result<object> element::get_object() const noexcept { return get<object>(); }
|
||||
inline simdjson_result<const char *> element::get_c_str() const noexcept { return get<const char *>(); }
|
||||
inline simdjson_result<std::string_view> element::get_string() const noexcept { return get<std::string_view>(); }
|
||||
inline simdjson_result<int64_t> element::get_int64_t() const noexcept { return get<int64_t>(); }
|
||||
inline simdjson_result<uint64_t> element::get_uint64_t() const noexcept { return get<uint64_t>(); }
|
||||
inline simdjson_result<double> element::get_double() const noexcept { return get<double>(); }
|
||||
inline simdjson_result<bool> element::get_bool() const noexcept { return get<bool>(); }
|
||||
|
||||
inline bool element::is_array() const noexcept { return is<array>(); }
|
||||
inline bool element::is_object() const noexcept { return is<object>(); }
|
||||
inline bool element::is_string() const noexcept { return is<std::string_view>(); }
|
||||
inline bool element::is_int64_t() const noexcept { return is<int64_t>(); }
|
||||
inline bool element::is_uint64_t() const noexcept { return is<uint64_t>(); }
|
||||
inline bool element::is_double() const noexcept { return is<double>(); }
|
||||
inline bool element::is_bool() const noexcept { return is<bool>(); }
|
||||
|
||||
inline bool element::is_null() const noexcept {
|
||||
return tape.is_null_on_tape();
|
||||
}
|
||||
|
||||
#if SIMDJSON_EXCEPTIONS
|
||||
|
||||
inline element::operator bool() const noexcept(false) { return get<bool>(); }
|
||||
|
|
|
@ -1370,12 +1370,12 @@ namespace type_tests {
|
|||
|
||||
RUN_TEST( tester.test_get(element) );
|
||||
RUN_TEST( tester.test_get(result) );
|
||||
// RUN_TEST( tester.test_named_get(element) );
|
||||
// RUN_TEST( tester.test_named_get(result) );
|
||||
RUN_TEST( tester.test_named_get(element) );
|
||||
RUN_TEST( tester.test_named_get(result) );
|
||||
RUN_TEST( tester.test_is(element, true) );
|
||||
RUN_TEST( tester.test_is(result, true) );
|
||||
// RUN_TEST( tester.test_named_is(element, true) );
|
||||
// RUN_TEST( tester.test_named_is(result, true) );
|
||||
RUN_TEST( tester.test_named_is(element, true) );
|
||||
RUN_TEST( tester.test_named_is(result, true) );
|
||||
#if SIMDJSON_EXCEPTIONS
|
||||
RUN_TEST( tester.test_implicit_cast(element) );
|
||||
RUN_TEST( tester.test_implicit_cast(result) );
|
||||
|
@ -1396,12 +1396,12 @@ namespace type_tests {
|
|||
|
||||
RUN_TEST( tester.test_get_error(element, expected_error) );
|
||||
RUN_TEST( tester.test_get_error(result, expected_error) );
|
||||
// RUN_TEST( tester.test_named_get_error(element, expected_error) );
|
||||
// RUN_TEST( tester.test_named_get_error(result, expected_error) );
|
||||
RUN_TEST( tester.test_named_get_error(element, expected_error) );
|
||||
RUN_TEST( tester.test_named_get_error(result, expected_error) );
|
||||
RUN_TEST( tester.test_is(element, false) );
|
||||
RUN_TEST( tester.test_is(result, false) );
|
||||
// RUN_TEST( tester.test_named_is(element, false) );
|
||||
// RUN_TEST( tester.test_named_is(result, false) );
|
||||
RUN_TEST( tester.test_named_is(element, false) );
|
||||
RUN_TEST( tester.test_named_is(result, false) );
|
||||
#if SIMDJSON_EXCEPTIONS
|
||||
RUN_TEST( tester.test_implicit_cast_error(element, expected_error) );
|
||||
RUN_TEST( tester.test_implicit_cast_error(result, expected_error) );
|
||||
|
|
|
@ -37,20 +37,20 @@ public:
|
|||
bool test_is(simdjson_result<element> element, bool expected);
|
||||
bool test_is_error(simdjson_result<element> element, error_code expected_error);
|
||||
|
||||
// bool test_named_get(element element, T expected = {});
|
||||
// bool test_named_get(simdjson_result<element> element, T expected = {});
|
||||
// bool test_named_get_error(element element, error_code expected_error);
|
||||
// bool test_named_get_error(simdjson_result<element> element, error_code expected_error);
|
||||
bool test_named_get(element element, T expected = {});
|
||||
bool test_named_get(simdjson_result<element> element, T expected = {});
|
||||
bool test_named_get_error(element element, error_code expected_error);
|
||||
bool test_named_get_error(simdjson_result<element> element, error_code expected_error);
|
||||
|
||||
// bool test_named_is(element element, bool expected);
|
||||
// bool test_named_is(simdjson_result<element> element, bool expected);
|
||||
// bool test_named_is_error(simdjson_result<element> element, error_code expected_error);
|
||||
bool test_named_is(element element, bool expected);
|
||||
bool test_named_is(simdjson_result<element> element, bool expected);
|
||||
bool test_named_is_error(simdjson_result<element> element, error_code expected_error);
|
||||
|
||||
private:
|
||||
// simdjson_result<T> named_get(element element);
|
||||
// simdjson_result<T> named_get(simdjson_result<element> element);
|
||||
// bool named_is(element element);
|
||||
// simdjson_result<bool> named_is(simdjson_result<element> element);
|
||||
simdjson_result<T> named_get(element element);
|
||||
simdjson_result<T> named_get(simdjson_result<element> element);
|
||||
bool named_is(element element);
|
||||
simdjson_result<bool> named_is(simdjson_result<element> element);
|
||||
bool assert_equal(const T& expected, const T& actual);
|
||||
};
|
||||
|
||||
|
@ -90,41 +90,41 @@ bool cast_tester<T>::test_get_error(simdjson_result<element> element, error_code
|
|||
return true;
|
||||
}
|
||||
|
||||
// template<typename T>
|
||||
// bool cast_tester<T>::test_named_get(element element, T expected) {
|
||||
// T actual;
|
||||
// error_code error;
|
||||
// named_get(element).tie(actual, error);
|
||||
// ASSERT_SUCCESS(error);
|
||||
// return assert_equal(actual, expected);
|
||||
// }
|
||||
template<typename T>
|
||||
bool cast_tester<T>::test_named_get(element element, T expected) {
|
||||
T actual;
|
||||
error_code error;
|
||||
named_get(element).tie(actual, error);
|
||||
ASSERT_SUCCESS(error);
|
||||
return assert_equal(actual, expected);
|
||||
}
|
||||
|
||||
// template<typename T>
|
||||
// bool cast_tester<T>::test_named_get(simdjson_result<element> element, T expected) {
|
||||
// T actual;
|
||||
// error_code error;
|
||||
// named_get(element).tie(actual, error);
|
||||
// ASSERT_SUCCESS(error);
|
||||
// return assert_equal(actual, expected);
|
||||
// }
|
||||
template<typename T>
|
||||
bool cast_tester<T>::test_named_get(simdjson_result<element> element, T expected) {
|
||||
T actual;
|
||||
error_code error;
|
||||
named_get(element).tie(actual, error);
|
||||
ASSERT_SUCCESS(error);
|
||||
return assert_equal(actual, expected);
|
||||
}
|
||||
|
||||
// template<typename T>
|
||||
// bool cast_tester<T>::test_named_get_error(element element, error_code expected_error) {
|
||||
// T actual;
|
||||
// error_code error;
|
||||
// named_get(element).tie(actual, error);
|
||||
// ASSERT_EQUAL(error, expected_error);
|
||||
// return true;
|
||||
// }
|
||||
template<typename T>
|
||||
bool cast_tester<T>::test_named_get_error(element element, error_code expected_error) {
|
||||
T actual;
|
||||
error_code error;
|
||||
named_get(element).tie(actual, error);
|
||||
ASSERT_EQUAL(error, expected_error);
|
||||
return true;
|
||||
}
|
||||
|
||||
// template<typename T>
|
||||
// bool cast_tester<T>::test_named_get_error(simdjson_result<element> element, error_code expected_error) {
|
||||
// T actual;
|
||||
// error_code error;
|
||||
// named_get(element).tie(actual, error);
|
||||
// ASSERT_EQUAL(error, expected_error);
|
||||
// return true;
|
||||
// }
|
||||
template<typename T>
|
||||
bool cast_tester<T>::test_named_get_error(simdjson_result<element> element, error_code expected_error) {
|
||||
T actual;
|
||||
error_code error;
|
||||
named_get(element).tie(actual, error);
|
||||
ASSERT_EQUAL(error, expected_error);
|
||||
return true;
|
||||
}
|
||||
|
||||
#if SIMDJSON_EXCEPTIONS
|
||||
|
||||
|
@ -208,72 +208,72 @@ bool cast_tester<T>::test_is_error(simdjson_result<element> element, error_code
|
|||
return true;
|
||||
}
|
||||
|
||||
// template<typename T>
|
||||
// bool cast_tester<T>::test_named_is(element element, bool expected) {
|
||||
// ASSERT_EQUAL(named_is(element), expected);
|
||||
// return true;
|
||||
// }
|
||||
template<typename T>
|
||||
bool cast_tester<T>::test_named_is(element element, bool expected) {
|
||||
ASSERT_EQUAL(named_is(element), expected);
|
||||
return true;
|
||||
}
|
||||
|
||||
// template<typename T>
|
||||
// bool cast_tester<T>::test_named_is(simdjson_result<element> element, bool expected) {
|
||||
// bool actual;
|
||||
// error_code error;
|
||||
// named_is(element).tie(actual, error);
|
||||
// ASSERT_SUCCESS(error);
|
||||
// ASSERT_EQUAL(actual, expected);
|
||||
// return true;
|
||||
// }
|
||||
template<typename T>
|
||||
bool cast_tester<T>::test_named_is(simdjson_result<element> element, bool expected) {
|
||||
bool actual;
|
||||
error_code error;
|
||||
named_is(element).tie(actual, error);
|
||||
ASSERT_SUCCESS(error);
|
||||
ASSERT_EQUAL(actual, expected);
|
||||
return true;
|
||||
}
|
||||
|
||||
// template<typename T>
|
||||
// bool cast_tester<T>::test_named_is_error(simdjson_result<element> element, error_code expected_error) {
|
||||
// bool actual;
|
||||
// error_code error;
|
||||
// named_is(element, error).tie(actual, error);
|
||||
// ASSERT_EQUAL(error, expected_error);
|
||||
// return true;
|
||||
// }
|
||||
template<typename T>
|
||||
bool cast_tester<T>::test_named_is_error(simdjson_result<element> element, error_code expected_error) {
|
||||
bool actual;
|
||||
error_code error;
|
||||
named_is(element, error).tie(actual, error);
|
||||
ASSERT_EQUAL(error, expected_error);
|
||||
return true;
|
||||
}
|
||||
|
||||
// template<> simdjson_result<array> cast_tester<array>::named_get(element element) { return element.get_array(); }
|
||||
// template<> simdjson_result<object> cast_tester<object>::named_get(element element) { return element.get_object(); }
|
||||
// template<> simdjson_result<const char *> cast_tester<const char *>::named_get(element element) { return element.get_c_str(); }
|
||||
// template<> simdjson_result<std::string_view> cast_tester<std::string_view>::named_get(element element) { return element.get_string(); }
|
||||
// template<> simdjson_result<uint64_t> cast_tester<uint64_t>::named_get(element element) { return element.get_uint64_t(); }
|
||||
// template<> simdjson_result<int64_t> cast_tester<int64_t>::named_get(element element) { return element.get_int64_t(); }
|
||||
// template<> simdjson_result<double> cast_tester<double>::named_get(element element) { return element.get_double(); }
|
||||
// template<> simdjson_result<bool> cast_tester<bool>::named_get(element element) { return element.get_bool(); }
|
||||
template<> simdjson_result<array> cast_tester<array>::named_get(element element) { return element.get_array(); }
|
||||
template<> simdjson_result<object> cast_tester<object>::named_get(element element) { return element.get_object(); }
|
||||
template<> simdjson_result<const char *> cast_tester<const char *>::named_get(element element) { return element.get_c_str(); }
|
||||
template<> simdjson_result<std::string_view> cast_tester<std::string_view>::named_get(element element) { return element.get_string(); }
|
||||
template<> simdjson_result<uint64_t> cast_tester<uint64_t>::named_get(element element) { return element.get_uint64_t(); }
|
||||
template<> simdjson_result<int64_t> cast_tester<int64_t>::named_get(element element) { return element.get_int64_t(); }
|
||||
template<> simdjson_result<double> cast_tester<double>::named_get(element element) { return element.get_double(); }
|
||||
template<> simdjson_result<bool> cast_tester<bool>::named_get(element element) { return element.get_bool(); }
|
||||
|
||||
// template<> simdjson_result<array> cast_tester<array>::named_get(simdjson_result<element> element) { return element.get_array(); }
|
||||
// template<> simdjson_result<object> cast_tester<object>::named_get(simdjson_result<element> element) { return element.get_object(); }
|
||||
// template<> simdjson_result<const char *> cast_tester<const char *>::named_get(simdjson_result<element> element) { return element.get_c_str(); }
|
||||
// template<> simdjson_result<std::string_view> cast_tester<std::string_view>::named_get(simdjson_result<element> element) { return element.get_string(); }
|
||||
// template<> simdjson_result<uint64_t> cast_tester<uint64_t>::named_get(simdjson_result<element> element) { return element.get_uint64_t(); }
|
||||
// template<> simdjson_result<int64_t> cast_tester<int64_t>::named_get(simdjson_result<element> element) { return element.get_int64_t(); }
|
||||
// template<> simdjson_result<double> cast_tester<double>::named_get(simdjson_result<element> element) { return element.get_double(); }
|
||||
// template<> simdjson_result<bool> cast_tester<bool>::named_get(simdjson_result<element> element) { return element.get_bool(); }
|
||||
template<> simdjson_result<array> cast_tester<array>::named_get(simdjson_result<element> element) { return element.get_array(); }
|
||||
template<> simdjson_result<object> cast_tester<object>::named_get(simdjson_result<element> element) { return element.get_object(); }
|
||||
template<> simdjson_result<const char *> cast_tester<const char *>::named_get(simdjson_result<element> element) { return element.get_c_str(); }
|
||||
template<> simdjson_result<std::string_view> cast_tester<std::string_view>::named_get(simdjson_result<element> element) { return element.get_string(); }
|
||||
template<> simdjson_result<uint64_t> cast_tester<uint64_t>::named_get(simdjson_result<element> element) { return element.get_uint64_t(); }
|
||||
template<> simdjson_result<int64_t> cast_tester<int64_t>::named_get(simdjson_result<element> element) { return element.get_int64_t(); }
|
||||
template<> simdjson_result<double> cast_tester<double>::named_get(simdjson_result<element> element) { return element.get_double(); }
|
||||
template<> simdjson_result<bool> cast_tester<bool>::named_get(simdjson_result<element> element) { return element.get_bool(); }
|
||||
|
||||
// template<> bool cast_tester<array>::named_is(element element) { return element.is_array(); }
|
||||
// template<> bool cast_tester<object>::named_is(element element) { return element.is_object(); }
|
||||
// template<> bool cast_tester<const char *>::named_is(element element) { return element.is_string(); }
|
||||
// template<> bool cast_tester<std::string_view>::named_is(element element) { return element.is_string(); }
|
||||
// template<> bool cast_tester<uint64_t>::named_is(element element) { return element.is_uint64_t(); }
|
||||
// template<> bool cast_tester<int64_t>::named_is(element element) { return element.is_int64_t(); }
|
||||
// template<> bool cast_tester<double>::named_is(element element) { return element.is_double(); }
|
||||
// template<> bool cast_tester<bool>::named_is(element element) { return element.is_bool(); }
|
||||
template<> bool cast_tester<array>::named_is(element element) { return element.is_array(); }
|
||||
template<> bool cast_tester<object>::named_is(element element) { return element.is_object(); }
|
||||
template<> bool cast_tester<const char *>::named_is(element element) { return element.is_string(); }
|
||||
template<> bool cast_tester<std::string_view>::named_is(element element) { return element.is_string(); }
|
||||
template<> bool cast_tester<uint64_t>::named_is(element element) { return element.is_uint64_t(); }
|
||||
template<> bool cast_tester<int64_t>::named_is(element element) { return element.is_int64_t(); }
|
||||
template<> bool cast_tester<double>::named_is(element element) { return element.is_double(); }
|
||||
template<> bool cast_tester<bool>::named_is(element element) { return element.is_bool(); }
|
||||
|
||||
// template<> simdjson_result<bool> cast_tester<array>::named_is(simdjson_result<element> element) { return element.is_array(); }
|
||||
// template<> simdjson_result<bool> cast_tester<object>::named_is(simdjson_result<element> element) { return element.is_object(); }
|
||||
// template<> simdjson_result<bool> cast_tester<const char *>::named_is(simdjson_result<element> element) { return element.is_string(); }
|
||||
// template<> simdjson_result<bool> cast_tester<std::string_view>::named_is(simdjson_result<element> element) { return element.is_string(); }
|
||||
// template<> simdjson_result<bool> cast_tester<uint64_t>::named_is(simdjson_result<element> element) { return element.is_uint64_t(); }
|
||||
// template<> simdjson_result<bool> cast_tester<int64_t>::named_is(simdjson_result<element> element) { return element.is_int64_t(); }
|
||||
// template<> simdjson_result<bool> cast_tester<double>::named_is(simdjson_result<element> element) { return element.is_double(); }
|
||||
// template<> simdjson_result<bool> cast_tester<bool>::named_is(simdjson_result<element> element) { return element.is_bool(); }
|
||||
template<> simdjson_result<bool> cast_tester<array>::named_is(simdjson_result<element> element) { return element.is_array(); }
|
||||
template<> simdjson_result<bool> cast_tester<object>::named_is(simdjson_result<element> element) { return element.is_object(); }
|
||||
template<> simdjson_result<bool> cast_tester<const char *>::named_is(simdjson_result<element> element) { return element.is_string(); }
|
||||
template<> simdjson_result<bool> cast_tester<std::string_view>::named_is(simdjson_result<element> element) { return element.is_string(); }
|
||||
template<> simdjson_result<bool> cast_tester<uint64_t>::named_is(simdjson_result<element> element) { return element.is_uint64_t(); }
|
||||
template<> simdjson_result<bool> cast_tester<int64_t>::named_is(simdjson_result<element> element) { return element.is_int64_t(); }
|
||||
template<> simdjson_result<bool> cast_tester<double>::named_is(simdjson_result<element> element) { return element.is_double(); }
|
||||
template<> simdjson_result<bool> cast_tester<bool>::named_is(simdjson_result<element> element) { return element.is_bool(); }
|
||||
|
||||
template<typename T> bool cast_tester<T>::assert_equal(const T& expected, const T& actual) {
|
||||
ASSERT_EQUAL(expected, actual);
|
||||
return true;
|
||||
}
|
||||
// We don't actually check objects and arrays, just check that they actually cast
|
||||
// We don't actually check equality for objects and arrays, just check that they actually cast
|
||||
template<> bool cast_tester<array>::assert_equal(const array&, const array&) {
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue