22 : xml(*config.getXML())
24 , debuggable(
std::in_place,
25 config.getMotherBoard(), name, description, *this)
39 if (
const auto* init = xml.
findChild(
"initialContent")) {
41 auto encoding = init->getAttributeValue(
"encoding");
43 if (encoding ==
"gz-base64") {
44 auto buf = Base64::decode(init->getData());
45 auto dstLen = narrow<uLongf>(
size());
46 if (uncompress(std::bit_cast<Bytef*>(ram.
data()), &dstLen,
47 std::bit_cast<const Bytef*>(buf.data()), uLong(buf.size()))
49 throw MSXException(
"Error while decompressing initialContent.");
52 }
else if (encoding ==
one_of(
"hex",
"base64")) {
53 auto buf = (encoding ==
"hex")
54 ? HexDump::decode(init->getData())
55 : Base64 ::decode(init->getData());
59 done = std::min(
size(), buf.size());
63 "\" for initialContent");
67 auto left =
size() - done;
69 auto tmp = std::min(done, left);
83 return debuggable->getName();
87 const std::string& name_,
101 ram[address] = value;
105template<
typename Archive>
109 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
This file implemented 3 utility functions:
constexpr void fill(ForwardRange &&range, const T &value)
constexpr auto copy(InputRange &&range, OutputIter out)
constexpr To narrow(From from) noexcept
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)