optionally disable deprecated apis (#1271)
Introduce cmake option SIMDJSON_DISABLE_DEPRECATED_API (default Off) which turns off deprecated simdjson api functions by setting the macro SIMDJSON_DISABLE_DEPRECATED_API. For non-cmake users, users will have to set SIMDJSON_DISABLE_DEPRECATED_API by some other means to disable the api. Closes #1264
This commit is contained in:
parent
b7fe764e6c
commit
f93fb21c95
|
@ -8,8 +8,8 @@ using namespace std;
|
|||
|
||||
const padded_string EMPTY_ARRAY("[]", 2);
|
||||
|
||||
const char *TWITTER_JSON = SIMDJSON_BENCHMARK_DATA_DIR "twitter.json";
|
||||
const char *NUMBERS_JSON = SIMDJSON_BENCHMARK_DATA_DIR "numbers.json";
|
||||
static const char *TWITTER_JSON = SIMDJSON_BENCHMARK_DATA_DIR "twitter.json";
|
||||
static const char *NUMBERS_JSON = SIMDJSON_BENCHMARK_DATA_DIR "numbers.json";
|
||||
|
||||
static void recover_one_string(State& state) {
|
||||
dom::parser parser;
|
||||
|
@ -472,6 +472,7 @@ static void twitter_count(State& state) {
|
|||
}
|
||||
BENCHMARK(twitter_count);
|
||||
|
||||
#ifndef SIMDJSON_DISABLE_DEPRECATED_API
|
||||
SIMDJSON_PUSH_DISABLE_WARNINGS
|
||||
SIMDJSON_DISABLE_DEPRECATED_WARNING
|
||||
static void iterator_twitter_count(State& state) {
|
||||
|
@ -491,6 +492,7 @@ static void iterator_twitter_count(State& state) {
|
|||
}
|
||||
BENCHMARK(iterator_twitter_count);
|
||||
SIMDJSON_POP_DISABLE_WARNINGS
|
||||
#endif // SIMDJSON_DISABLE_DEPRECATED_API
|
||||
|
||||
static void twitter_default_profile(State& state) {
|
||||
// Count unique users with a default profile.
|
||||
|
@ -575,8 +577,11 @@ static void error_code_twitter_default_profile(State& state) noexcept {
|
|||
}
|
||||
BENCHMARK(error_code_twitter_default_profile);
|
||||
|
||||
#ifndef SIMDJSON_DISABLE_DEPRECATED_API
|
||||
|
||||
SIMDJSON_PUSH_DISABLE_WARNINGS
|
||||
SIMDJSON_DISABLE_DEPRECATED_WARNING
|
||||
|
||||
static void iterator_twitter_default_profile(State& state) {
|
||||
// Count unique users with a default profile.
|
||||
padded_string json;
|
||||
|
@ -615,8 +620,10 @@ static void iterator_twitter_default_profile(State& state) {
|
|||
if (default_users.size() != 86) { return; }
|
||||
}
|
||||
}
|
||||
|
||||
SIMDJSON_POP_DISABLE_WARNINGS
|
||||
BENCHMARK(iterator_twitter_default_profile);
|
||||
#endif // SIMDJSON_DISABLE_DEPRECATED_API
|
||||
|
||||
static void error_code_twitter_image_sizes(State& state) noexcept {
|
||||
// Count unique image sizes
|
||||
|
@ -648,6 +655,8 @@ static void error_code_twitter_image_sizes(State& state) noexcept {
|
|||
}
|
||||
BENCHMARK(error_code_twitter_image_sizes);
|
||||
|
||||
#ifndef SIMDJSON_DISABLE_DEPRECATED_API
|
||||
|
||||
SIMDJSON_PUSH_DISABLE_WARNINGS
|
||||
SIMDJSON_DISABLE_DEPRECATED_WARNING
|
||||
static void iterator_twitter_image_sizes(State& state) {
|
||||
|
@ -711,6 +720,9 @@ static void iterator_twitter_image_sizes(State& state) {
|
|||
}
|
||||
BENCHMARK(iterator_twitter_image_sizes);
|
||||
|
||||
#endif // SIMDJSON_DISABLE_DEPRECATED_API
|
||||
|
||||
#ifndef SIMDJSON_DISABLE_DEPRECATED_API
|
||||
static void print_json(State& state) noexcept {
|
||||
// Prints the number of results in twitter.json
|
||||
dom::parser parser;
|
||||
|
@ -727,6 +739,7 @@ static void print_json(State& state) noexcept {
|
|||
}
|
||||
}
|
||||
BENCHMARK(print_json);
|
||||
#endif // SIMDJSON_DISABLE_DEPRECATED_API
|
||||
SIMDJSON_POP_DISABLE_WARNINGS
|
||||
|
||||
BENCHMARK_MAIN();
|
||||
BENCHMARK_MAIN();
|
||||
|
|
|
@ -111,6 +111,7 @@ BENCHMARK(parse_gsoc)->Repetitions(10)->ComputeStatistics("max", [](const std::v
|
|||
|
||||
|
||||
|
||||
#ifndef SIMDJSON_DISABLE_DEPRECATED_API
|
||||
SIMDJSON_PUSH_DISABLE_WARNINGS
|
||||
SIMDJSON_DISABLE_DEPRECATED_WARNING
|
||||
static void json_parse(State& state) {
|
||||
|
@ -123,6 +124,8 @@ static void json_parse(State& state) {
|
|||
}
|
||||
SIMDJSON_POP_DISABLE_WARNINGS
|
||||
BENCHMARK(json_parse);
|
||||
#endif // SIMDJSON_DISABLE_DEPRECATED_API
|
||||
|
||||
static void parser_parse_error_code(State& state) {
|
||||
dom::parser parser;
|
||||
if (parser.allocate(EMPTY_ARRAY.length())) { return; }
|
||||
|
@ -151,6 +154,7 @@ BENCHMARK(parser_parse_exception);
|
|||
|
||||
#endif // SIMDJSON_EXCEPTIONS
|
||||
|
||||
#ifndef SIMDJSON_DISABLE_DEPRECATED_API
|
||||
SIMDJSON_PUSH_DISABLE_WARNINGS
|
||||
SIMDJSON_DISABLE_DEPRECATED_WARNING
|
||||
static void build_parsed_json(State& state) {
|
||||
|
@ -162,6 +166,8 @@ static void build_parsed_json(State& state) {
|
|||
SIMDJSON_POP_DISABLE_WARNINGS
|
||||
|
||||
BENCHMARK(build_parsed_json);
|
||||
#endif
|
||||
|
||||
static void document_parse_error_code(State& state) {
|
||||
for (simdjson_unused auto _ : state) {
|
||||
dom::parser parser;
|
||||
|
|
|
@ -217,6 +217,11 @@ if (SIMDJSON_VERBOSE_LOGGING)
|
|||
target_compile_definitions(simdjson-flags INTERFACE SIMDJSON_VERBOSE_LOGGING=1)
|
||||
endif()
|
||||
|
||||
option(SIMDJSON_DISABLE_DEPRECATED_API "Disables deprecated APIs" Off)
|
||||
if (SIMDJSON_DISABLE_DEPRECATED_API)
|
||||
target_compile_definitions(simdjson-flags INTERFACE SIMDJSON_DISABLE_DEPRECATED_API=1)
|
||||
endif()
|
||||
|
||||
if(SIMDJSON_USE_LIBCPP)
|
||||
target_link_libraries(simdjson-flags INTERFACE -stdlib=libc++ -lc++abi)
|
||||
# instead of the above line, we could have used
|
||||
|
|
|
@ -24,7 +24,7 @@ fi
|
|||
set -u
|
||||
|
||||
# common options
|
||||
COMMON="-GNinja -DCMAKE_CXX_COMPILER=clang++$CLANGSUFFIX -DCMAKE_C_COMPILER=clang$CLANGSUFFIX -DSIMDJSON_BUILD_STATIC=Off -DENABLE_FUZZING=On -DSIMDJSON_COMPETITION=OFF -DSIMDJSON_GOOGLE_BENCHMARKS=OFF -DSIMDJSON_GIT=Off"
|
||||
COMMON="-GNinja -DCMAKE_CXX_COMPILER=clang++$CLANGSUFFIX -DCMAKE_C_COMPILER=clang$CLANGSUFFIX -DSIMDJSON_BUILD_STATIC=Off -DENABLE_FUZZING=On -DSIMDJSON_COMPETITION=OFF -DSIMDJSON_GOOGLE_BENCHMARKS=OFF -DSIMDJSON_GIT=Off -DSIMDJSON_DISABLE_DEPRECATED_API=On"
|
||||
|
||||
# A replay build, as plain as it gets. For use with valgrind/gdb.
|
||||
variant=replay
|
||||
|
|
|
@ -25,6 +25,7 @@ if [ ! -d $bdir ] ; then
|
|||
-DCMAKE_BUILD_TYPE=Debug \
|
||||
-DSIMDJSON_BUILD_STATIC=On \
|
||||
-DENABLE_FUZZING=On \
|
||||
-DSIMDJSON_DISABLE_DEPRECATED_API=On \
|
||||
-DSIMDJSON_FUZZ_LINKMAIN=On
|
||||
ninja all_fuzzers
|
||||
cd ..
|
||||
|
|
|
@ -32,6 +32,7 @@ cmake .. \
|
|||
-DSIMDJSON_FUZZ_LINKMAIN=Off \
|
||||
-DSIMDJSON_GIT=Off \
|
||||
-DSIMDJSON_GOOGLE_BENCHMARKS=Off \
|
||||
-DSIMDJSON_DISABLE_DEPRECATED_API=On \
|
||||
-DSIMDJSON_FUZZ_LDFLAGS=$LIB_FUZZING_ENGINE
|
||||
|
||||
cmake --build . --target all_fuzzers
|
||||
|
|
|
@ -259,6 +259,7 @@ simdjson_really_inline dom::document_stream::iterator simdjson_result<dom::docum
|
|||
return first.end();
|
||||
}
|
||||
#else // SIMDJSON_EXCEPTIONS
|
||||
#ifndef SIMDJSON_DISABLE_DEPRECATED_API
|
||||
simdjson_really_inline dom::document_stream::iterator simdjson_result<dom::document_stream>::begin() noexcept {
|
||||
first.error = error();
|
||||
return first.begin();
|
||||
|
@ -267,6 +268,7 @@ simdjson_really_inline dom::document_stream::iterator simdjson_result<dom::docum
|
|||
first.error = error();
|
||||
return first.end();
|
||||
}
|
||||
#endif // SIMDJSON_DISABLE_DEPRECATED_API
|
||||
#endif // SIMDJSON_EXCEPTIONS
|
||||
|
||||
} // namespace simdjson
|
||||
|
|
|
@ -278,10 +278,12 @@ public:
|
|||
simdjson_really_inline dom::document_stream::iterator begin() noexcept(false);
|
||||
simdjson_really_inline dom::document_stream::iterator end() noexcept(false);
|
||||
#else // SIMDJSON_EXCEPTIONS
|
||||
#ifndef SIMDJSON_DISABLE_DEPRECATED_API
|
||||
[[deprecated("parse_many() and load_many() may return errors. Use document_stream stream; error = parser.parse_many().get(doc); instead.")]]
|
||||
simdjson_really_inline dom::document_stream::iterator begin() noexcept;
|
||||
[[deprecated("parse_many() and load_many() may return errors. Use document_stream stream; error = parser.parse_many().get(doc); instead.")]]
|
||||
simdjson_really_inline dom::document_stream::iterator end() noexcept;
|
||||
#endif // SIMDJSON_DISABLE_DEPRECATED_API
|
||||
#endif // SIMDJSON_EXCEPTIONS
|
||||
}; // struct simdjson_result<dom::document_stream>
|
||||
|
||||
|
|
|
@ -116,6 +116,7 @@ simdjson_really_inline simdjson_result<dom::element> simdjson_result<dom::elemen
|
|||
if (error()) { return error(); }
|
||||
return first.at_pointer(json_pointer);
|
||||
}
|
||||
#ifndef SIMDJSON_DISABLE_DEPRECATED_API
|
||||
[[deprecated("For standard compliance, use at_pointer instead, and prefix your pointers with a slash '/', see RFC6901 ")]]
|
||||
simdjson_really_inline simdjson_result<dom::element> simdjson_result<dom::element>::at(const std::string_view json_pointer) const noexcept {
|
||||
SIMDJSON_PUSH_DISABLE_WARNINGS
|
||||
|
@ -124,6 +125,7 @@ SIMDJSON_DISABLE_DEPRECATED_WARNING
|
|||
return first.at(json_pointer);
|
||||
SIMDJSON_POP_DISABLE_WARNINGS
|
||||
}
|
||||
#endif // SIMDJSON_DISABLE_DEPRECATED_API
|
||||
simdjson_really_inline simdjson_result<dom::element> simdjson_result<dom::element>::at(size_t index) const noexcept {
|
||||
if (error()) { return error(); }
|
||||
return first.at(index);
|
||||
|
@ -373,13 +375,14 @@ inline simdjson_result<element> element::at_pointer(std::string_view json_pointe
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef SIMDJSON_DISABLE_DEPRECATED_API
|
||||
[[deprecated("For standard compliance, use at_pointer instead, and prefix your pointers with a slash '/', see RFC6901 ")]]
|
||||
inline simdjson_result<element> element::at(std::string_view json_pointer) const noexcept {
|
||||
// version 0.4 of simdjson allowed non-compliant pointers
|
||||
auto std_pointer = (json_pointer.empty() ? "" : "/") + std::string(json_pointer.begin(), json_pointer.end());
|
||||
return at_pointer(std_pointer);
|
||||
}
|
||||
#endif // SIMDJSON_DISABLE_DEPRECATED_API
|
||||
|
||||
inline simdjson_result<element> element::at(size_t index) const noexcept {
|
||||
return get<array>().at(index);
|
||||
|
|
|
@ -410,7 +410,8 @@ public:
|
|||
* - INVALID_JSON_POINTER if the JSON pointer is invalid and cannot be parsed
|
||||
*/
|
||||
inline simdjson_result<element> at_pointer(const std::string_view json_pointer) const noexcept;
|
||||
|
||||
|
||||
#ifndef SIMDJSON_DISABLE_DEPRECATED_API
|
||||
/**
|
||||
*
|
||||
* Version 0.4 of simdjson used an incorrect interpretation of the JSON Pointer standard
|
||||
|
@ -433,6 +434,7 @@ public:
|
|||
*/
|
||||
[[deprecated("For standard compliance, use at_pointer instead, and prefix your pointers with a slash '/', see RFC6901 ")]]
|
||||
inline simdjson_result<element> at(const std::string_view json_pointer) const noexcept;
|
||||
#endif // SIMDJSON_DISABLE_DEPRECATED_API
|
||||
|
||||
/**
|
||||
* Get the value at the given index.
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace simdjson {
|
|||
// C API (json_parse and build_parsed_json) declarations
|
||||
//
|
||||
|
||||
#ifndef SIMDJSON_DISABLE_DEPRECATED_API
|
||||
[[deprecated("Use parser.parse() instead")]]
|
||||
inline int json_parse(const uint8_t *buf, size_t len, dom::parser &parser, bool realloc_if_needed = true) noexcept {
|
||||
error_code code = parser.parse(buf, len, realloc_if_needed).error();
|
||||
|
@ -106,6 +107,7 @@ simdjson_warn_unused inline dom::parser build_parsed_json(const padded_string &s
|
|||
parser.error = code;
|
||||
return parser;
|
||||
}
|
||||
#endif // SIMDJSON_DISABLE_DEPRECATED_API
|
||||
|
||||
/** @private We do not want to allow implicit conversion from C string to std::string. */
|
||||
int json_parse(const char *buf, dom::parser &parser) noexcept = delete;
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#include "simdjson/portability.h"
|
||||
#include <cstring>
|
||||
|
||||
#ifndef SIMDJSON_DISABLE_DEPRECATED_API
|
||||
|
||||
namespace simdjson {
|
||||
|
||||
// VS2017 reports deprecated warnings when you define a deprecated class's methods.
|
||||
|
@ -12,7 +14,6 @@ SIMDJSON_PUSH_DISABLE_WARNINGS
|
|||
SIMDJSON_DISABLE_DEPRECATED_WARNING
|
||||
|
||||
// Because of template weirdness, the actual class definition is inline in the document class
|
||||
|
||||
simdjson_warn_unused bool dom::parser::Iterator::is_ok() const {
|
||||
return location < tape_length;
|
||||
}
|
||||
|
@ -480,7 +481,9 @@ bool dom::parser::Iterator::relative_move_to(const char *pointer,
|
|||
}
|
||||
|
||||
SIMDJSON_POP_DISABLE_WARNINGS
|
||||
|
||||
} // namespace simdjson
|
||||
|
||||
#endif // SIMDJSON_DISABLE_DEPRECATED_API
|
||||
|
||||
|
||||
#endif // SIMDJSON_INLINE_PARSEDJSON_ITERATOR_H
|
||||
|
|
|
@ -14,8 +14,9 @@
|
|||
#include "simdjson/dom/parsedjson.h"
|
||||
#include "simdjson/internal/jsonformatutils.h"
|
||||
|
||||
namespace simdjson {
|
||||
#ifndef SIMDJSON_DISABLE_DEPRECATED_API
|
||||
|
||||
namespace simdjson {
|
||||
/** @private **/
|
||||
class [[deprecated("Use the new DOM navigation API instead (see doc/basics.md)")]] dom::parser::Iterator {
|
||||
public:
|
||||
|
@ -266,5 +267,6 @@ public:
|
|||
};
|
||||
|
||||
} // namespace simdjson
|
||||
#endif // SIMDJSON_DISABLE_DEPRECATED_API
|
||||
|
||||
#endif // SIMDJSON_DOM_PARSEDJSON_ITERATOR_H
|
||||
|
|
|
@ -160,11 +160,12 @@ inline error_code parser::allocate(size_t capacity, size_t max_depth) noexcept {
|
|||
return SUCCESS;
|
||||
}
|
||||
|
||||
#ifndef SIMDJSON_DISABLE_DEPRECATED_API
|
||||
simdjson_warn_unused
|
||||
inline bool parser::allocate_capacity(size_t capacity, size_t max_depth) noexcept {
|
||||
return !allocate(capacity, max_depth);
|
||||
}
|
||||
|
||||
#endif // SIMDJSON_DISABLE_DEPRECATED_API
|
||||
inline error_code parser::ensure_capacity(size_t desired_capacity) noexcept {
|
||||
// If we don't have enough capacity, (try to) automatically bump it.
|
||||
// If the document was taken, reallocate that too.
|
||||
|
|
|
@ -374,6 +374,7 @@ public:
|
|||
*/
|
||||
simdjson_warn_unused inline error_code allocate(size_t capacity, size_t max_depth = DEFAULT_MAX_DEPTH) noexcept;
|
||||
|
||||
#ifndef SIMDJSON_DISABLE_DEPRECATED_API
|
||||
/**
|
||||
* @private deprecated because it returns bool instead of error_code, which is our standard for
|
||||
* failures. Use allocate() instead.
|
||||
|
@ -387,7 +388,7 @@ public:
|
|||
*/
|
||||
[[deprecated("Use allocate() instead.")]]
|
||||
simdjson_warn_unused inline bool allocate_capacity(size_t capacity, size_t max_depth = DEFAULT_MAX_DEPTH) noexcept;
|
||||
|
||||
#endif // SIMDJSON_DISABLE_DEPRECATED_API
|
||||
/**
|
||||
* The largest document this parser can support without reallocating.
|
||||
*
|
||||
|
|
|
@ -24,12 +24,14 @@ inline const char *error_message(error_code error) noexcept {
|
|||
}
|
||||
|
||||
// deprecated function
|
||||
#ifndef SIMDJSON_DISABLE_DEPRECATED_API
|
||||
inline const std::string error_message(int error) noexcept {
|
||||
if (error < 0 || error >= error_code::NUM_ERROR_CODES) {
|
||||
return internal::error_codes[UNEXPECTED_ERROR].message;
|
||||
}
|
||||
return internal::error_codes[error].message;
|
||||
}
|
||||
#endif // SIMDJSON_DISABLE_DEPRECATED_API
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& out, error_code error) noexcept {
|
||||
return out << error_message(error);
|
||||
|
|
|
@ -251,6 +251,7 @@ struct simdjson_result : public internal::simdjson_result_base<T> {
|
|||
#endif // SIMDJSON_EXCEPTIONS
|
||||
}; // struct simdjson_result
|
||||
|
||||
#ifndef SIMDJSON_DISABLE_DEPRECATED_API
|
||||
/**
|
||||
* @deprecated This is an alias and will be removed, use error_code instead
|
||||
*/
|
||||
|
@ -261,7 +262,7 @@ using ErrorValues [[deprecated("This is an alias and will be removed, use error_
|
|||
*/
|
||||
[[deprecated("Error codes should be stored and returned as `error_code`, use `error_message()` instead.")]]
|
||||
inline const std::string error_message(int error) noexcept;
|
||||
|
||||
#endif // SIMDJSON_DISABLE_DEPRECATED_API
|
||||
} // namespace simdjson
|
||||
|
||||
#endif // SIMDJSON_ERROR_H
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
namespace simdjson {
|
||||
|
||||
#if SIMDJSON_EXCEPTIONS
|
||||
|
||||
#ifndef SIMDJSON_DISABLE_DEPRECATED_API
|
||||
[[deprecated("Use padded_string::load() instead")]]
|
||||
inline padded_string get_corpus(const char *path) {
|
||||
return padded_string::load(path);
|
||||
}
|
||||
|
||||
#endif // SIMDJSON_DISABLE_DEPRECATED_API
|
||||
#endif // SIMDJSON_EXCEPTIONS
|
||||
|
||||
} // namespace simdjson
|
||||
|
|
|
@ -375,6 +375,7 @@ namespace parse_api_tests {
|
|||
return true;
|
||||
}
|
||||
|
||||
#ifdef SIMDJSON_ENABLE_DEPRECATED_API
|
||||
SIMDJSON_PUSH_DISABLE_WARNINGS
|
||||
SIMDJSON_DISABLE_DEPRECATED_WARNING
|
||||
bool parser_parse_many_deprecated() {
|
||||
|
@ -390,6 +391,7 @@ namespace parse_api_tests {
|
|||
return true;
|
||||
}
|
||||
SIMDJSON_POP_DISABLE_WARNINGS
|
||||
#endif // SIMDJSON_ENABLE_DEPRECATED_API
|
||||
bool parser_parse_many_empty() {
|
||||
std::cout << "Running " << __func__ << std::endl;
|
||||
dom::parser parser;
|
||||
|
@ -454,6 +456,7 @@ namespace parse_api_tests {
|
|||
return true;
|
||||
}
|
||||
|
||||
#ifdef SIMDJSON_ENABLE_DEPRECATED_API
|
||||
SIMDJSON_PUSH_DISABLE_WARNINGS
|
||||
SIMDJSON_DISABLE_DEPRECATED_WARNING
|
||||
bool parser_load_many_deprecated() {
|
||||
|
@ -475,7 +478,7 @@ namespace parse_api_tests {
|
|||
return true;
|
||||
}
|
||||
SIMDJSON_POP_DISABLE_WARNINGS
|
||||
|
||||
#endif // SIMDJSON_ENABLE_DEPRECATED_API
|
||||
#if SIMDJSON_EXCEPTIONS
|
||||
|
||||
bool parser_parse_exception() {
|
||||
|
@ -522,12 +525,16 @@ namespace parse_api_tests {
|
|||
return parser_moving_parser() &&
|
||||
parser_parse() &&
|
||||
parser_parse_many() &&
|
||||
#ifdef SIMDJSON_ENABLE_DEPRECATED_API
|
||||
parser_parse_many_deprecated() &&
|
||||
#endif
|
||||
parser_parse_many_empty() &&
|
||||
parser_parse_many_empty_batches() &&
|
||||
parser_load() &&
|
||||
parser_load_many() &&
|
||||
#ifdef SIMDJSON_ENABLE_DEPRECATED_API
|
||||
parser_load_many_deprecated() &&
|
||||
#endif
|
||||
#if SIMDJSON_EXCEPTIONS
|
||||
parser_parse_exception() &&
|
||||
parser_parse_many_exception() &&
|
||||
|
@ -545,6 +552,9 @@ namespace dom_api_tests {
|
|||
|
||||
SIMDJSON_PUSH_DISABLE_WARNINGS
|
||||
SIMDJSON_DISABLE_DEPRECATED_WARNING
|
||||
|
||||
#ifdef SIMDJSON_ENABLE_DEPRECATED_API
|
||||
|
||||
// returns true if successful
|
||||
bool ParsedJson_Iterator_test() {
|
||||
std::cout << "Running " << __func__ << std::endl;
|
||||
|
@ -567,6 +577,7 @@ namespace dom_api_tests {
|
|||
printf("Could not parse '%s': %s\n", json.data(), simdjson::error_message(pj.error));
|
||||
return false;
|
||||
}
|
||||
|
||||
simdjson::ParsedJson::Iterator iter(pj);
|
||||
if (!iter.is_object()) {
|
||||
printf("Root should be object\n");
|
||||
|
@ -646,6 +657,8 @@ namespace dom_api_tests {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
#endif // SIMDJSON_ENABLE_DEPRECATED_API
|
||||
|
||||
SIMDJSON_POP_DISABLE_WARNINGS
|
||||
|
||||
bool object_iterator() {
|
||||
|
@ -1055,7 +1068,10 @@ namespace dom_api_tests {
|
|||
#endif
|
||||
|
||||
bool run() {
|
||||
return ParsedJson_Iterator_test() &&
|
||||
return
|
||||
#if SIMDJSON_ENABLE_DEPRECATED_API
|
||||
ParsedJson_Iterator_test() &&
|
||||
#endif
|
||||
object_iterator() &&
|
||||
array_iterator() &&
|
||||
object_iterator_empty() &&
|
||||
|
|
|
@ -109,6 +109,7 @@ bool json_pointer_failure_test(const padded_string & source, const char *json_po
|
|||
return true;
|
||||
}
|
||||
|
||||
#ifdef SIMDJSON_ENABLE_DEPRECATED_API
|
||||
SIMDJSON_PUSH_DISABLE_WARNINGS
|
||||
SIMDJSON_DISABLE_DEPRECATED_WARNING
|
||||
// for pre 0.4 users (not standard compliant)
|
||||
|
@ -132,6 +133,7 @@ bool legacy_support() {
|
|||
return true;
|
||||
}
|
||||
SIMDJSON_POP_DISABLE_WARNINGS
|
||||
#endif // #if SIMDJSON_ENABLE_DEPRECATED_API
|
||||
|
||||
// for 0.5 version and following (standard compliant)
|
||||
bool modern_support() {
|
||||
|
@ -191,7 +193,9 @@ int main() {
|
|||
if (true
|
||||
&& demo()
|
||||
&& issue1142()
|
||||
#ifdef SIMDJSON_ENABLE_DEPRECATED_API
|
||||
&& legacy_support()
|
||||
#endif
|
||||
&& modern_support()
|
||||
&& json_pointer_success_test(TEST_RFC_JSON, "", R"({"foo":["bar","baz"],"":0,"a/b":1,"c%d":2,"e^f":3,"g|h":4,"i\\j":5,"k\"l":6," ":7,"m~n":8})")
|
||||
&& json_pointer_success_test(TEST_RFC_JSON, "/foo", "[\"bar\",\"baz\"]")
|
||||
|
|
Loading…
Reference in New Issue