2021-10-10 20:26:30 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
2021-10-11 13:59:23 +00:00
|
|
|
|
|
|
|
#ifdef USE_BOOST_JSON
|
|
|
|
# include <boost/json.hpp>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef USE_NLOHMANN_JSON
|
|
|
|
# include "nlohmann/json.hpp"
|
|
|
|
#endif
|
2021-10-10 20:26:30 +00:00
|
|
|
|
2021-10-11 18:13:05 +00:00
|
|
|
#ifdef USE_JSONCPP_JSON
|
|
|
|
# include <memory>
|
|
|
|
# include <json/json.h>
|
|
|
|
#endif
|
|
|
|
|
2021-10-11 21:09:03 +00:00
|
|
|
#ifdef USE_SIMDJSON_JSON
|
|
|
|
# include "simdjson/simdjson.h"
|
|
|
|
#endif
|
|
|
|
|
2021-10-10 20:26:30 +00:00
|
|
|
class opcode_test_suite_t final {
|
|
|
|
private:
|
2021-10-12 09:10:45 +00:00
|
|
|
#ifdef JSON_PREFER_REUSE_OF_PARSER
|
2021-10-11 18:13:05 +00:00
|
|
|
#ifdef USE_JSONCPP_JSON
|
2021-10-11 22:23:59 +00:00
|
|
|
static std::unique_ptr<Json::CharReader> m_parser;
|
2021-10-11 18:13:05 +00:00
|
|
|
#endif
|
2021-10-11 21:09:03 +00:00
|
|
|
#ifdef USE_SIMDJSON_JSON
|
2021-10-12 09:10:45 +00:00
|
|
|
// N.B.
|
|
|
|
// The parser must be kept for the lifetime of any parsed data.
|
|
|
|
// Therefore, it can only be used for one document at a time.
|
|
|
|
static simdjson::dom::parser m_parser;
|
|
|
|
#endif
|
2021-10-11 21:09:03 +00:00
|
|
|
#endif
|
2021-10-11 18:13:05 +00:00
|
|
|
|
2021-10-11 09:43:33 +00:00
|
|
|
[[nodiscard]] static std::string read(std::string path);
|
2021-10-10 20:26:30 +00:00
|
|
|
|
|
|
|
std::string m_path;
|
2021-10-12 16:07:45 +00:00
|
|
|
std::string m_contents;
|
2021-10-11 13:59:23 +00:00
|
|
|
#ifdef USE_BOOST_JSON
|
2021-10-10 20:26:30 +00:00
|
|
|
boost::json::value m_raw;
|
2021-10-11 13:59:23 +00:00
|
|
|
#endif
|
|
|
|
#ifdef USE_NLOHMANN_JSON
|
|
|
|
nlohmann::json m_raw;
|
|
|
|
#endif
|
2021-10-11 18:13:05 +00:00
|
|
|
#ifdef USE_JSONCPP_JSON
|
|
|
|
Json::Value m_raw;
|
|
|
|
#endif
|
2021-10-11 21:09:03 +00:00
|
|
|
#ifdef USE_SIMDJSON_JSON
|
|
|
|
simdjson::dom::element m_raw;
|
2021-10-12 09:10:45 +00:00
|
|
|
#ifndef JSON_PREFER_REUSE_OF_PARSER
|
|
|
|
// N.B. The parser must be kept for the lifetime of any parsed data.
|
|
|
|
simdjson::dom::parser m_parser;
|
|
|
|
#endif
|
2021-10-11 21:09:03 +00:00
|
|
|
#endif
|
2021-10-10 20:26:30 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
opcode_test_suite_t(std::string path);
|
|
|
|
|
2021-10-11 09:43:33 +00:00
|
|
|
[[nodiscard]] constexpr const auto& path() const noexcept { return m_path; }
|
2021-10-11 21:09:03 +00:00
|
|
|
|
|
|
|
#ifdef JSON_PREFER_PASS_BY_VALUE
|
|
|
|
[[nodiscard]] const auto raw() const noexcept { return m_raw; }
|
|
|
|
#else
|
2021-10-11 09:43:33 +00:00
|
|
|
[[nodiscard]] constexpr const auto& raw() const noexcept { return m_raw; }
|
2021-10-11 21:09:03 +00:00
|
|
|
#endif
|
2021-10-11 13:59:23 +00:00
|
|
|
|
2021-10-12 16:07:45 +00:00
|
|
|
void load(); // Reads into contents
|
|
|
|
void parse(); // Parse the contents
|
2021-10-10 20:26:30 +00:00
|
|
|
};
|