Move json_type to ondemand to prevent target mismatch inline errors
This commit is contained in:
parent
2ed24666b5
commit
9944db6d73
|
@ -43,14 +43,12 @@ SIMDJSON_DISABLE_UNDESIRED_WARNINGS
|
|||
// Public API
|
||||
#include "simdjson/simdjson_version.h"
|
||||
#include "simdjson/error.h"
|
||||
#include "simdjson/json_type.h"
|
||||
#include "simdjson/minify.h"
|
||||
#include "simdjson/padded_string.h"
|
||||
#include "simdjson/implementation.h"
|
||||
|
||||
// Inline functions
|
||||
#include "simdjson/error-inl.h"
|
||||
#include "simdjson/json_type-inl.h"
|
||||
#include "simdjson/padded_string-inl.h"
|
||||
|
||||
// DOM
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include "simdjson/generic/ondemand/json_type-inl.h"
|
||||
#include "simdjson/generic/ondemand/logger-inl.h"
|
||||
#include "simdjson/generic/ondemand/raw_json_string-inl.h"
|
||||
#include "simdjson/generic/ondemand/token_iterator-inl.h"
|
||||
|
|
|
@ -14,6 +14,7 @@ using depth_t = int32_t;
|
|||
} // namespace SIMDJSON_IMPLEMENTATION
|
||||
} // namespace simdjson
|
||||
|
||||
#include "simdjson/generic/ondemand/json_type.h"
|
||||
#include "simdjson/generic/ondemand/token_position.h"
|
||||
#include "simdjson/generic/ondemand/logger.h"
|
||||
#include "simdjson/generic/ondemand/raw_json_string.h"
|
||||
|
|
|
@ -243,7 +243,7 @@ template<> simdjson_really_inline error_code simdjson_result<SIMDJSON_IMPLEMENTA
|
|||
return SUCCESS;
|
||||
}
|
||||
|
||||
simdjson_really_inline simdjson_result<json_type> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::type() noexcept {
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::json_type> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::type() noexcept {
|
||||
if (error()) { return error(); }
|
||||
return first.type();
|
||||
}
|
||||
|
|
|
@ -349,7 +349,7 @@ public:
|
|||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> find_field_unordered(std::string_view key) & noexcept;
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> find_field_unordered(const char *key) & noexcept;
|
||||
|
||||
simdjson_really_inline simdjson_result<json_type> type() noexcept;
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::json_type> type() noexcept;
|
||||
};
|
||||
|
||||
} // namespace simdjson
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
namespace simdjson {
|
||||
namespace SIMDJSON_IMPLEMENTATION {
|
||||
namespace ondemand {
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& out, json_type type) noexcept {
|
||||
switch (type) {
|
||||
case json_type::array: out << "array"; break;
|
||||
case json_type::object: out << "object"; break;
|
||||
case json_type::number: out << "number"; break;
|
||||
case json_type::string: out << "string"; break;
|
||||
case json_type::boolean: out << "boolean"; break;
|
||||
case json_type::null: out << "null"; break;
|
||||
default: SIMDJSON_UNREACHABLE();
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
#if SIMDJSON_EXCEPTIONS
|
||||
inline std::ostream& operator<<(std::ostream& out, simdjson_result<json_type> &type) noexcept(false) {
|
||||
return out << type.value();
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace ondemand
|
||||
} // namespace SIMDJSON_IMPLEMENTATION
|
||||
} // namespace simdjson
|
||||
|
||||
namespace simdjson {
|
||||
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::json_type>::simdjson_result(SIMDJSON_IMPLEMENTATION::ondemand::json_type &&value) noexcept
|
||||
: implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::json_type>(std::forward<SIMDJSON_IMPLEMENTATION::ondemand::json_type>(value)) {}
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::json_type>::simdjson_result(error_code error) noexcept
|
||||
: implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::json_type>(error) {}
|
||||
|
||||
} // namespace simdjson
|
|
@ -1,9 +1,6 @@
|
|||
#ifndef SIMDJSON_JSON_TYPE_H
|
||||
#define SIMDJSON_JSON_TYPE_H
|
||||
|
||||
#include "simdjson/common_defs.h"
|
||||
|
||||
namespace simdjson {
|
||||
namespace SIMDJSON_IMPLEMENTATION {
|
||||
namespace ondemand {
|
||||
|
||||
/**
|
||||
* The type of a JSON value.
|
||||
|
@ -39,6 +36,19 @@ inline std::ostream& operator<<(std::ostream& out, json_type type) noexcept;
|
|||
inline std::ostream& operator<<(std::ostream& out, simdjson_result<json_type> &type) noexcept(false);
|
||||
#endif
|
||||
|
||||
} // namespace ondemand
|
||||
} // namespace SIMDJSON_IMPLEMENTATION
|
||||
} // namespace simdjson
|
||||
|
||||
#endif // SIMDJSON_JSON_TYPE_H
|
||||
namespace simdjson {
|
||||
|
||||
template<>
|
||||
struct simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::json_type> : public SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::json_type> {
|
||||
public:
|
||||
simdjson_really_inline simdjson_result(SIMDJSON_IMPLEMENTATION::ondemand::json_type &&value) noexcept; ///< @private
|
||||
simdjson_really_inline simdjson_result(error_code error) noexcept; ///< @private
|
||||
simdjson_really_inline simdjson_result() noexcept = default;
|
||||
simdjson_really_inline ~simdjson_result() noexcept = default; ///< @private
|
||||
};
|
||||
|
||||
} // namespace simdjson
|
|
@ -234,7 +234,7 @@ template<> simdjson_really_inline error_code simdjson_result<SIMDJSON_IMPLEMENTA
|
|||
return SUCCESS;
|
||||
}
|
||||
|
||||
simdjson_really_inline simdjson_result<json_type> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::type() noexcept {
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::json_type> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::type() noexcept {
|
||||
if (error()) { return error(); }
|
||||
return first.type();
|
||||
}
|
||||
|
|
|
@ -413,7 +413,7 @@ public:
|
|||
* better to just call .get_double, .get_string, etc. and check for INCORRECT_TYPE (or just
|
||||
* let it throw an exception).
|
||||
*/
|
||||
simdjson_really_inline simdjson_result<json_type> type() noexcept;
|
||||
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::json_type> type() noexcept;
|
||||
};
|
||||
|
||||
} // namespace simdjson
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
#ifndef SIMDJSON_JSON_TYPE_INL_H
|
||||
#define SIMDJSON_JSON_TYPE_INL_H
|
||||
|
||||
#include "simdjson/json_type.h"
|
||||
|
||||
namespace simdjson {
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& out, json_type type) noexcept {
|
||||
switch (type) {
|
||||
case json_type::array: out << "array"; break;
|
||||
case json_type::object: out << "object"; break;
|
||||
case json_type::number: out << "number"; break;
|
||||
case json_type::string: out << "string"; break;
|
||||
case json_type::boolean: out << "boolean"; break;
|
||||
case json_type::null: out << "null"; break;
|
||||
default: SIMDJSON_UNREACHABLE();
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
#if SIMDJSON_EXCEPTIONS
|
||||
inline std::ostream& operator<<(std::ostream& out, simdjson_result<json_type> &type) noexcept(false) {
|
||||
return out << type.value();
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace simdjson
|
||||
|
||||
#endif // SIMDJSON_JSON_TYPE_INL_H
|
|
@ -5,6 +5,7 @@ using namespace simdjson;
|
|||
|
||||
namespace array_tests {
|
||||
using namespace std;
|
||||
using simdjson::ondemand::json_type;
|
||||
|
||||
bool iterate_document_array() {
|
||||
TEST_START();
|
||||
|
|
|
@ -5,6 +5,7 @@ using namespace simdjson;
|
|||
|
||||
namespace object_tests {
|
||||
using namespace std;
|
||||
using simdjson::ondemand::json_type;
|
||||
|
||||
bool iterate_object() {
|
||||
TEST_START();
|
||||
|
|
|
@ -5,6 +5,8 @@ using namespace simdjson;
|
|||
|
||||
namespace scalar_tests {
|
||||
using namespace std;
|
||||
using simdjson::ondemand::json_type;
|
||||
|
||||
template<typename T> json_type expected_json_type();
|
||||
template<> json_type expected_json_type<std::string_view>() { return json_type::string; }
|
||||
template<> json_type expected_json_type<double>() { return json_type::number; }
|
||||
|
|
Loading…
Reference in New Issue