EightBit/M6502/HarteTest_6502/cycles_t.cpp
Adrian Conlon 9cd317624e Couple of extra safety checks.
Signed-off-by: Adrian Conlon <adrian.conlon@gmail.com>
2021-10-18 12:28:15 +01:00

59 lines
1.1 KiB
C++

#include "stdafx.h"
#include "cycles_t.h"
cycles_t::cycles_t(size_t reserved) {
m_cycles.reserve(reserved);
}
void cycles_t::add(const cycle_t& cycle) {
assert(m_cycles.capacity() >= (m_cycles.size() + 1));
m_cycles.push_back(cycle);
}
#ifdef USE_SIMDJSON_JSON
cycles_t::cycles_t(simdjson::dom::array input) {
assert(m_cycles.empty());
m_cycles.reserve(input.size());
for (const auto& entry : input)
add(entry);
}
#endif
#ifdef USE_BOOST_JSON
cycles_t::cycles_t(const boost::json::value& input)
: cycles_t(input.as_array()) {}
cycles_t::cycles_t(const boost::json::array& input) {
assert(m_cycles.empty());
m_cycles.reserve(input.size());
for (const auto& entry : input)
add(entry);
}
#endif
#ifdef USE_NLOHMANN_JSON
cycles_t::cycles_t(const nlohmann::json& input) {
assert(m_cycles.empty());
m_cycles.reserve(input.size());
for (const auto& entry : input)
add(entry);
}
#endif
#ifdef USE_JSONCPP_JSON
cycles_t::cycles_t(const Json::Value& input) {
assert(m_cycles.empty());
m_cycles.reserve(input.size());
for (const auto& entry : input)
add(entry);
}
#endif