openMSX
IPSPatch.hh
Go to the documentation of this file.
1#ifndef IPSPATCH_HH
2#define IPSPATCH_HH
3
4#include "PatchInterface.hh"
5#include "Filename.hh"
6#include <vector>
7#include <memory>
8
9namespace openmsx {
10
11class IPSPatch final : public PatchInterface
12{
13public:
14 IPSPatch(Filename filename,
15 std::unique_ptr<const PatchInterface> parent);
16
17 void copyBlock(size_t src, std::span<uint8_t> dst) const override;
18 [[nodiscard]] size_t getSize() const override { return size; }
19 [[nodiscard]] std::vector<Filename> getFilenames() const override;
20
21private:
22 struct Chunk {
23 Chunk(size_t s, std::vector<uint8_t>&& c)
24 : startAddress(s), content(std::move(c)) {} // clang-15 workaround
25
26 size_t startAddress;
27 std::vector<uint8_t> content;
28
29 [[nodiscard]] size_t size() const { return content.size(); }
30 [[nodiscard]] size_t stopAddress() const { return startAddress + size(); }
31 [[nodiscard]] auto begin() const { return content.begin(); }
32 [[nodiscard]] auto end () const { return content.end(); }
33 };
34
35 const Filename filename;
36 const std::unique_ptr<const PatchInterface> parent;
37 const std::vector<Chunk> chunks; // sorted on startAddress
38 const size_t size;
39
40private:
41 // Helper functions called from constructor
42 [[nodiscard]] std::vector<Chunk> parseChunks() const;
43 [[nodiscard]] size_t calcSize() const;
44};
45
46} // namespace openmsx
47
48#endif
This class represents a filename.
Definition Filename.hh:20
void copyBlock(size_t src, std::span< uint8_t > dst) const override
Definition IPSPatch.cc:89
size_t getSize() const override
Definition IPSPatch.hh:18
std::vector< Filename > getFilenames() const override
Definition IPSPatch.cc:131
This file implemented 3 utility functions:
Definition Autofire.cc:11
STL namespace.
size_t size(std::string_view utf8)
constexpr auto begin(const zstring_view &x)
constexpr auto end(const zstring_view &x)