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 Image;
10 class Reader;
11 class Writer;
12
17 {
18 public:
19 virtual ~Contents() = default;
25 virtual offset_t ImageSize() const = 0;
29 virtual offset_t WriteFile(const std::shared_ptr<Writer>& wr) const = 0;
33 virtual std::shared_ptr<const Image> AsImage() const;
37 std::shared_ptr<Image> AsImage();
38 };
39
40 class Image : public Contents, public std::enable_shared_from_this<Image>
41 {
42 public:
43 std::shared_ptr<const Image> AsImage() const override;
44
53 virtual size_t ReadData(size_t bytes, offset_t offset, void * buffer) const = 0;
54
56 uint64_t ReadUnsigned(size_t bytes, offset_t offset, EndianType endiantype) const;
57
59 uint64_t ReadUnsigned(size_t bytes, offset_t offset) const;
60
62 int64_t ReadSigned(size_t bytes, offset_t offset, EndianType endiantype) const;
63
65 int64_t ReadSigned(size_t bytes, offset_t offset) const;
66
70 int GetByte(offset_t offset) const;
71
73
77 virtual offset_t WriteFile(const std::shared_ptr<Writer>& wr, offset_t count, offset_t offset = 0) const;
78
79 offset_t WriteFile(const std::shared_ptr<Writer>& wr) const override;
80 };
81}
82
83#endif /* IMAGE_H */
Represents abstract data contents whose data can be written to a file.
Definition image.h:17
virtual offset_t ImageSize() const =0
Retrieves the offset of the byte after the last one belonging to this format from the first one.
virtual std::shared_ptr< const Image > AsImage() const
Retrieves a randomly accessible image.
Definition image.cc:10
virtual offset_t WriteFile(const std::shared_ptr< Writer > &wr) const =0
Writes data of non-zero filled sections.
Definition image.h:41
int GetByte(offset_t offset) const
Retrieve byte at a certain offset (optional, might not be defined)
Definition image.cc:63
int64_t ReadSigned(size_t bytes, offset_t offset, EndianType endiantype) const
Reads a signed number at a specific offset.
Definition image.cc:51
uint64_t ReadUnsigned(size_t bytes, offset_t offset, EndianType endiantype) const
Reads an unsigned number at a specific offset.
Definition image.cc:39
virtual size_t ReadData(size_t bytes, offset_t offset, void *buffer) const =0
Attempts to fill a buffer with data.
virtual offset_t WriteFile(const std::shared_ptr< Writer > &wr, offset_t count, offset_t offset=0) const
Writes data of non-zero filled sections.
Definition image.cc:68
std::shared_ptr< const Image > AsImage() const override
Retrieves a randomly accessible image.
Definition image.cc:34