2021-10-18 12:12:22 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#ifdef USE_SIMDJSON_JSON
|
|
|
|
# include "simdjson/simdjson.h"
|
|
|
|
#endif
|
|
|
|
|
2021-10-18 23:39:26 +00:00
|
|
|
#ifdef USE_RAPIDJSON_JSON
|
2021-10-19 08:28:13 +00:00
|
|
|
# include "rapidjson/document.h"
|
2021-10-18 23:39:26 +00:00
|
|
|
#endif
|
|
|
|
|
2021-10-18 12:12:22 +00:00
|
|
|
#ifdef USE_BOOST_JSON
|
|
|
|
# include <boost/json.hpp>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef USE_NLOHMANN_JSON
|
|
|
|
# include "nlohmann/json.hpp"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef USE_JSONCPP_JSON
|
|
|
|
# include <json/json.h>
|
|
|
|
#endif
|
|
|
|
|
2021-10-19 08:28:13 +00:00
|
|
|
#include "byte_t.h"
|
|
|
|
|
|
|
|
class ram_t final {
|
2021-10-18 12:12:22 +00:00
|
|
|
private:
|
2021-10-19 08:28:13 +00:00
|
|
|
std::vector<byte_t> m_bytes;
|
2021-10-18 12:12:22 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
#ifdef USE_SIMDJSON_JSON
|
|
|
|
ram_t(simdjson::dom::array input);
|
|
|
|
#endif
|
|
|
|
|
2021-10-18 23:39:26 +00:00
|
|
|
#ifdef USE_RAPIDJSON_JSON
|
|
|
|
ram_t(const rapidjson::Value& input);
|
|
|
|
#endif
|
|
|
|
|
2021-10-18 12:12:22 +00:00
|
|
|
#ifdef USE_BOOST_JSON
|
|
|
|
ram_t(const boost::json::value& input);
|
|
|
|
ram_t(const boost::json::array& input);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef USE_NLOHMANN_JSON
|
|
|
|
ram_t(const nlohmann::json& input);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef USE_JSONCPP_JSON
|
|
|
|
ram_t(const Json::Value& input);
|
|
|
|
#endif
|
|
|
|
|
2021-10-19 08:28:13 +00:00
|
|
|
void add(const byte_t& byte);
|
|
|
|
|
2021-10-18 16:19:28 +00:00
|
|
|
[[nodiscard]] auto begin() const noexcept { return m_bytes.begin(); }
|
|
|
|
[[nodiscard]] auto end() const noexcept { return m_bytes.end(); }
|
2021-10-18 12:12:22 +00:00
|
|
|
|
|
|
|
[[nodiscard]] auto size() const noexcept { return m_bytes.size(); }
|
|
|
|
|
2021-10-18 16:19:28 +00:00
|
|
|
void clear() noexcept { m_bytes.clear(); }
|
2021-10-18 12:12:22 +00:00
|
|
|
|
2021-10-18 16:19:28 +00:00
|
|
|
[[nodiscard]] auto& operator[](size_t idx) noexcept { return m_bytes[idx]; }
|
|
|
|
[[nodiscard]] const auto& operator[](size_t idx) const noexcept { return m_bytes[idx]; }
|
2021-10-18 12:12:22 +00:00
|
|
|
};
|