2021-10-18 12:12:22 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include "ram_t.h"
|
|
|
|
|
|
|
|
#ifdef USE_SIMDJSON_JSON
|
|
|
|
|
|
|
|
ram_t::ram_t(simdjson::dom::array input) {
|
|
|
|
m_bytes.reserve(input.size());
|
|
|
|
for (const auto byte : input) {
|
|
|
|
assert(byte.is_array());
|
|
|
|
const auto ram_entry_array = byte.get_array();
|
|
|
|
assert(byte.size() == 2);
|
2021-10-18 19:40:13 +00:00
|
|
|
auto iterator = byte.begin();
|
|
|
|
const auto address = (uint16_t)(uint64_t)*iterator;
|
|
|
|
const auto value = (uint8_t)(uint64_t)*++iterator;
|
2021-10-18 12:12:22 +00:00
|
|
|
m_bytes.push_back({ address, value });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2021-10-18 23:39:26 +00:00
|
|
|
#ifdef USE_RAPIDJSON_JSON
|
|
|
|
|
|
|
|
ram_t::ram_t(const rapidjson::Value& input) {
|
|
|
|
m_bytes.reserve(input.Size());
|
2021-10-18 23:59:02 +00:00
|
|
|
for (const auto& byte : input.GetArray()) {
|
|
|
|
assert(byte.Size() == 2);
|
|
|
|
const auto address = (uint16_t)byte[0].GetInt64();
|
|
|
|
const auto value = (uint8_t)byte[1].GetInt64();
|
2021-10-18 23:39:26 +00:00
|
|
|
m_bytes.push_back({ address, value });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-10-18 12:12:22 +00:00
|
|
|
#ifdef USE_BOOST_JSON
|
|
|
|
|
|
|
|
ram_t::ram_t(const boost::json::array& input) {
|
|
|
|
m_bytes.reserve(input.size());
|
|
|
|
for (const auto& byte : input) {
|
2021-10-18 19:40:13 +00:00
|
|
|
const auto& ram_entry_array = byte.get_array();
|
2021-10-18 12:12:22 +00:00
|
|
|
assert(ram_entry_array.size() == 2);
|
2021-10-18 19:40:13 +00:00
|
|
|
const auto address = (uint16_t)ram_entry_array[0].get_int64();
|
|
|
|
const auto value = (uint8_t)ram_entry_array[1].get_int64();
|
2021-10-18 12:12:22 +00:00
|
|
|
m_bytes.push_back({ address, value });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
|
|
|
assert(input.is_array());
|
2021-10-18 19:40:13 +00:00
|
|
|
m_bytes.reserve(input.size());
|
2021-10-18 12:12:22 +00:00
|
|
|
for (const auto& byte : input) {
|
|
|
|
assert(byte.is_array());
|
|
|
|
assert(byte.size() == 2);
|
|
|
|
const auto address = byte[0].get<uint16_t>();
|
|
|
|
const auto value = byte[1].get<uint8_t>();
|
|
|
|
m_bytes.push_back({ address, value });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef USE_JSONCPP_JSON
|
|
|
|
|
|
|
|
ram_t::ram_t(const Json::Value& input) {
|
|
|
|
assert(input.isArray());
|
2021-10-18 19:40:13 +00:00
|
|
|
m_bytes.reserve(input.size());
|
2021-10-18 12:12:22 +00:00
|
|
|
for (const auto& byte : input) {
|
|
|
|
assert(byte.isArray());
|
|
|
|
assert(byte.size() == 2);
|
|
|
|
const auto address = byte[0].asUInt();
|
|
|
|
const auto value = byte[1].asUInt();
|
|
|
|
m_bytes.push_back({ address, value });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|