RetroLinker
Linker for several 8-bit, 16-bit and 32-bit formats
Loading...
Searching...
No Matches
image.h
1#ifndef IMAGE_H
2#define IMAGE_H
3
4#include <vector>
5#include "../common.h"
6
7namespace Linker
8{
9 class ActualImage;
10 class Reader;
11 class Writer;
12
16 class Image
17 {
18 public:
19 virtual ~Image() = default;
23 virtual offset_t ImageSize() const = 0;
27 virtual offset_t WriteFile(Writer& wr, offset_t count, offset_t offset = 0) const = 0;
31 virtual offset_t WriteFile(Writer& wr) const;
35 virtual std::shared_ptr<const ActualImage> AsImage() const;
39 std::shared_ptr<ActualImage> AsImage();
40 };
41
42 class ActualImage : public Image, public std::enable_shared_from_this<ActualImage>
43 {
44 public:
45 std::shared_ptr<const ActualImage> AsImage() const override;
46
55 virtual size_t ReadData(size_t bytes, offset_t offset, void * buffer) const = 0;
56
58 uint64_t ReadUnsigned(size_t bytes, offset_t offset, EndianType endiantype) const;
59
61 uint64_t ReadUnsigned(size_t bytes, offset_t offset) const;
62
64 int64_t ReadSigned(size_t bytes, offset_t offset, EndianType endiantype) const;
65
67 int64_t ReadSigned(size_t bytes, offset_t offset) const;
68
72 int GetByte(offset_t offset) const;
73 };
74}
75
76#endif /* IMAGE_H */
Definition image.h:43
int64_t ReadSigned(size_t bytes, offset_t offset, EndianType endiantype) const
Reads a signed number at a specific offset.
Definition image.cc:50
virtual size_t ReadData(size_t bytes, offset_t offset, void *buffer) const =0
Attempts to fill a buffer with data.
std::shared_ptr< const ActualImage > AsImage() const override
Retrieves a randomly accessible image.
Definition image.cc:33
uint64_t ReadUnsigned(size_t bytes, offset_t offset, EndianType endiantype) const
Reads an unsigned number at a specific offset.
Definition image.cc:38
int GetByte(offset_t offset) const
Retrieve byte at a certain offset (optional, might not be defined)
Definition image.cc:62
Represents an abstract data image whose data can be written to a file.
Definition image.h:17
virtual offset_t WriteFile(Writer &wr, offset_t count, offset_t offset=0) const =0
Writes data of non-zero filled sections.
virtual offset_t ImageSize() const =0
Retrieves size of stored data.
virtual std::shared_ptr< const ActualImage > AsImage() const
Retrieves a randomly accessible image.
Definition image.cc:10
A helper class, encapsulating functionality needed to export binary data.
Definition writer.h:15