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 size_t startAddress;
24 std::vector<uint8_t> content;
25
26 [[nodiscard]] size_t size() const { return content.size(); }
27 [[nodiscard]] size_t stopAddress() const { return startAddress + size(); }
28 [[nodiscard]] auto begin() const { return content.begin(); }
29 [[nodiscard]] auto end () const { return content.end(); }
30 };
31
32 const Filename filename;
33 const std::unique_ptr<const PatchInterface> parent;
34 const std::vector<Chunk> chunks; // sorted on startAddress
35 const size_t size;
36
37private:
38 // Helper functions called from constructor
39 [[nodiscard]] std::vector<Chunk> parseChunks() const;
40 [[nodiscard]] size_t calcSize() const;
41};
42
43} // namespace openmsx
44
45#endif
This class represents a filename.
Definition: Filename.hh:18
void copyBlock(size_t src, std::span< uint8_t > dst) const override
Definition: IPSPatch.cc:89
IPSPatch(Filename filename, std::unique_ptr< const PatchInterface > parent)
Definition: IPSPatch.cc:80
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:9
constexpr auto begin(const zstring_view &x)
constexpr auto end(const zstring_view &x)