2021-10-18 12:12:22 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include "ram_t.h"
|
|
|
|
|
2021-10-19 10:44:58 +00:00
|
|
|
void ram_t::add(byte_t byte) {
|
2021-10-19 08:28:13 +00:00
|
|
|
assert(m_bytes.capacity() >= (m_bytes.size() + 1));
|
|
|
|
m_bytes.push_back(byte);
|
|
|
|
}
|
|
|
|
|
2021-10-18 12:12:22 +00:00
|
|
|
#ifdef USE_SIMDJSON_JSON
|
|
|
|
|
|
|
|
ram_t::ram_t(simdjson::dom::array input) {
|
2021-10-19 08:28:13 +00:00
|
|
|
assert(m_bytes.empty());
|
2021-10-18 12:12:22 +00:00
|
|
|
m_bytes.reserve(input.size());
|
2021-10-19 10:44:58 +00:00
|
|
|
for (auto entry : input)
|
2021-10-19 08:28:13 +00:00
|
|
|
add(entry);
|
2021-10-18 12:12:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2021-10-18 23:39:26 +00:00
|
|
|
#ifdef USE_RAPIDJSON_JSON
|
|
|
|
|
|
|
|
ram_t::ram_t(const rapidjson::Value& input) {
|
2021-10-19 08:28:13 +00:00
|
|
|
assert(m_bytes.empty());
|
2021-10-18 23:39:26 +00:00
|
|
|
m_bytes.reserve(input.Size());
|
2021-10-19 08:28:13 +00:00
|
|
|
for (const auto& entry : input.GetArray())
|
|
|
|
add(entry);
|
2021-10-18 23:39:26 +00:00
|
|
|
}
|
2021-10-19 08:28:13 +00:00
|
|
|
|
2021-10-18 23:39:26 +00:00
|
|
|
#endif
|
|
|
|
|
2021-10-18 12:12:22 +00:00
|
|
|
#ifdef USE_BOOST_JSON
|
|
|
|
|
|
|
|
ram_t::ram_t(const boost::json::array& input) {
|
2021-10-19 08:28:13 +00:00
|
|
|
assert(m_bytes.empty());
|
2021-10-18 12:12:22 +00:00
|
|
|
m_bytes.reserve(input.size());
|
2021-10-19 08:28:13 +00:00
|
|
|
for (const auto& entry : input)
|
|
|
|
add(entry);
|
2021-10-18 12:12:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ram_t::ram_t(const boost::json::value& input)
|
2021-10-18 19:40:13 +00:00
|
|
|
: ram_t(input.get_array()) {}
|
2021-10-18 12:12:22 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef USE_NLOHMANN_JSON
|
|
|
|
|
|
|
|
ram_t::ram_t(const nlohmann::json& input) {
|
2021-10-19 08:28:13 +00:00
|
|
|
assert(m_bytes.empty());
|
2021-10-18 19:40:13 +00:00
|
|
|
m_bytes.reserve(input.size());
|
2021-10-19 08:28:13 +00:00
|
|
|
for (const auto& entry : input)
|
|
|
|
add(entry);
|
2021-10-18 12:12:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef USE_JSONCPP_JSON
|
|
|
|
|
|
|
|
ram_t::ram_t(const Json::Value& input) {
|
2021-10-19 08:28:13 +00:00
|
|
|
assert(m_bytes.empty());
|
2021-10-18 19:40:13 +00:00
|
|
|
m_bytes.reserve(input.size());
|
2021-10-19 08:28:13 +00:00
|
|
|
for (const auto& entry : input)
|
|
|
|
add(entry);
|
2021-10-18 12:12:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|