RetroLinker
Linker for several 8-bit, 16-bit and 32-bit formats
Loading...
Searching...
No Matches
buffer.h
1#ifndef BUFFER_H
2#define BUFFER_H
3
4#include <algorithm>
5#include <iostream>
6#include <string>
7#include <variant>
8#include <vector>
9#include "../common.h"
10#include "position.h"
11#include "reader.h"
12#include "writable.h"
13
14namespace Linker
15{
16 class Segment;
17
21 class Buffer : public Writable
22 {
23 protected:
24 std::vector<uint8_t> data;
25
26 public:
27 Buffer()
28 {
29 }
30
31 Buffer(size_t size)
32 {
33 data.resize(size);
34 }
35
36 offset_t ActualDataSize() override;
37 void ReadFile(Reader& rd);
38 void ReadFile(Reader& rd, offset_t count);
39 static std::shared_ptr<Buffer> ReadFromFile(Reader& rd);
40 static std::shared_ptr<Buffer> ReadFromFile(Reader& rd, offset_t count);
42 offset_t WriteFile(Writer& wr, offset_t count, offset_t offset = 0) override;
43 int GetByte(offset_t offset) override;
44
45 friend class Section;
46 };
47}
48
49#endif /* BUFFER_H */
A buffer that can be used to read and store data from a file.
Definition buffer.h:22
offset_t ActualDataSize() override
Retrieves size of stored data.
Definition buffer.cc:6
offset_t WriteFile(Writer &wr, offset_t count, offset_t offset=0) override
Writes data of non-zero filled sections.
Definition buffer.cc:40
int GetByte(offset_t offset) override
Retrieve byte at a certain offset (optional, might not be defined)
Definition buffer.cc:45
A helper class, encapsulating functionality needed to import binary data.
Definition reader.h:16
A section of data as read from an object file.
Definition section.h:25
Represents an abstract interface whose data can be written to a file.
Definition writable.h:15
virtual offset_t WriteFile(Writer &wr, offset_t count, offset_t offset=0)=0
Writes data of non-zero filled sections.
A helper class, encapsulating functionality needed to export binary data.
Definition writer.h:15