RetroLinker
Linker for several 8-bit, 16-bit and 32-bit formats
Loading...
Searching...
No Matches
position.h
1#ifndef POSITION_H
2#define POSITION_H
3
4#include "../common.h"
5
6namespace Linker
7{
8 class Segment;
9
17 {
18 public:
22 offset_t address;
26 std::shared_ptr<Segment> segment;
27
28 Position(offset_t address = 0, std::shared_ptr<Segment> segment = nullptr)
30 {
31 }
32
36 offset_t GetSegmentOffset() const;
37
41 Position& operator+=(offset_t value);
42
46 Position& operator-=(offset_t value);
47 };
48
52 Position operator+(Position a, offset_t b);
53
57 Position operator-(Position a, offset_t b);
58
62 bool operator ==(const Position& a, const Position& b);
63
67 bool operator !=(const Position& a, const Position& b);
68
69 std::ostream& operator<<(std::ostream& out, const Position& position); /* implemented separately to avoid circular references */
70}
71
72#endif /* POSITION_H */
Stores an absolute address along with the containing segment or address space.
Definition position.h:17
offset_t GetSegmentOffset() const
Returns the offset from the start of the segment.
Definition position.cc:9
offset_t address
The address of the position, independent of segment it belongs to.
Definition position.h:22
std::shared_ptr< Segment > segment
The segment or address space of the position.
Definition position.h:26
Position & operator-=(offset_t value)
Arithmetic on the address.
Definition position.cc:20
Position & operator+=(offset_t value)
Arithmetic on the address.
Definition position.cc:14