18 : xml(*config.getXML())
21 , debuggable(
std::in_place,
22 config.getMotherBoard(), name, description, *this)
37 if (
const auto* init = xml.
findChild(
"initialContent")) {
39 auto encoding = init->getAttributeValue(
"encoding");
41 if (encoding ==
"gz-base64") {
42 auto [buf, bufSize] = Base64::decode(init->getData());
43 auto dstLen = narrow<uLongf>(
size());
44 if (uncompress(
reinterpret_cast<Bytef*
>(ram.
data()), &dstLen,
45 reinterpret_cast<const Bytef*
>(buf.data()), uLong(bufSize))
47 throw MSXException(
"Error while decompressing initialContent.");
50 }
else if (encoding ==
one_of(
"hex",
"base64")) {
51 auto [buf, bufSize] = (encoding ==
"hex")
52 ? HexDump::decode(init->getData())
53 : Base64 ::decode(init->getData());
61 "\" for initialContent");
65 auto left =
size() - done;
80 return debuggable->getName();
84 const std::string& name_,
102template<
typename Archive>
106 ar.serialize_blob(
"ram", std::span{
begin(),
end()});
const T * data() const
Returns pointer to the start of the memory buffer.
byte read(unsigned address) override
void write(unsigned address, byte value) override
RamDebuggable(MSXMotherBoard &motherBoard, const std::string &name, static_string_view description, Ram &ram)
Ram(const DeviceConfig &config, const std::string &name, static_string_view description, size_t size)
Create Ram object with an associated debuggable.
void serialize(Archive &ar, unsigned version)
const std::string & getName() const
const XMLElement * findChild(std::string_view childName) const
constexpr vecN< N, T > min(const vecN< N, T > &x, const vecN< N, T > &y)
This file implemented 3 utility functions:
constexpr void fill(ForwardRange &&range, const T &value)
auto copy(InputRange &&range, OutputIter out)
size_t size(std::string_view utf8)
constexpr To narrow(From from) noexcept
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)