libart-paperback 0.1.0-a.1.20260122225059.e5fea306241a
PDF (1.4) library for C++
types.hxx
1#ifndef art__paperback__types_hxx_
2#define art__paperback__types_hxx_
3
4#include <cstdint>
5#include <deque>
6#include <initializer_list>
7#include <iostream>
8#include <list>
9#include <map>
10#include <memory>
11#include <optional>
12#include <sstream>
13#include <stack>
14#include <stdexcept>
15#include <string>
16#include <variant>
17#include <vector>
18
19namespace Art::Paperback
20{
21
22#ifndef GENERATING_DOCUMENTATION
23 using std::initializer_list;
24
25 using std::invalid_argument;
26 using std::logic_error;
27 using std::runtime_error;
28
29 using std::int8_t;
30 using std::int16_t;
31 using std::int32_t;
32 using std::int64_t;
33
34 using std::uint8_t;
35 using std::uint16_t;
36 using std::uint32_t;
37 using std::uint64_t;
38
39 using std::unique_ptr;
40 using std::shared_ptr;
41 using std::make_shared;
42 using std::make_unique;
43
44 using std::variant;
45 using std::holds_alternative;
46
47 using std::deque;
48 using std::list;
49 using std::map;
50 using std::stack;
51 using std::vector;
52
53 using std::optional;
54 using std::nullopt;
55
56 using std::string;
57
58 using std::istream;
59 using std::ostream;
60 using std::iostream;
61 using std::streampos;
62 using std::streamoff;
63 using std::stringstream;
64
65 using std::cin;
66 using std::cout;
67 using std::cerr;
68#endif
69
70 /// Index type.
71 ///
72 using Index = uint32_t;
73
74 /// Generation type.
75 ///
76 using Generation = uint16_t;
77
78 /// Represents the identity of an indirect object.
79 ///
80 struct Identity
81 {
82 /// Constructor.
83 ///
84 /// This constructor creates an identity with index 0 and
85 /// generation 0.
86 ///
88 {}
89
90 /// Constructor.
91 ///
92 /// \param index The index of the identity.
93 /// \param generation The generation of the identity.
94 ///
95 Identity(Index index, Generation generation)
96 : index{index}, generation{generation}
97 {}
98
99 Index index{};
100 Generation generation{};
101
102 /// Compare this identity with another.
103 ///
104 /// \param other The identity to compare with.
105 ///
106 bool
107 operator==(Identity const& other) const
108 {
109 return index == other.index && generation == other.generation;
110 }
111
112 /// Compare this identity with another.
113 ///
114 /// \param other The identity to compare with.
115 ///
116 bool
117 operator!=(Identity const& other) const
118 {
119 return !(*this == other);
120 }
121
122 /// Compare this identity with another.
123 ///
124 bool
125 operator<(Identity const& other) const
126 {
127 if (index < other.index) {
128 return true;
129 }
130
131 if (generation < other.generation) {
132 return true;
133 }
134
135 return false;
136 }
137
138 };
139
140} // namespace Art::Paperback
141
142#endif
Primary paperback namespace.
Definition array.cxx:6
uint16_t Generation
Generation type.
Definition types.hxx:76
uint32_t Index
Index type.
Definition types.hxx:72
bool operator==(Identity const &other) const
Compare this identity with another.
Definition types.hxx:107
Identity()
Constructor.
Definition types.hxx:87
Identity(Index index, Generation generation)
Constructor.
Definition types.hxx:95
bool operator!=(Identity const &other) const
Compare this identity with another.
Definition types.hxx:117
bool operator<(Identity const &other) const
Compare this identity with another.
Definition types.hxx:125