ORIGINAL
Loading...
Searching...
No Matches
containerAdapter.h
Go to the documentation of this file.
1#ifndef CONTAINERADAPTER_H
2#define CONTAINERADAPTER_H
3#include "baseList.h"
4#include "types.h"
5#include "printable.h"
6#include "comparable.h"
7
8
9namespace original {
17
46 template <typename TYPE,
47 template <typename, typename> typename SERIAL,
48 template <typename> typename ALLOC>
49 requires ExtendsOf<baseList<TYPE, ALLOC<TYPE>>, SERIAL<TYPE, ALLOC<TYPE>>>
51 : public printable,
52 public container<TYPE, ALLOC<TYPE>>,
53 public comparable<containerAdapter<TYPE, SERIAL, ALLOC>>{
54 protected:
60 SERIAL<TYPE, ALLOC<TYPE>> serial_;
61
71 explicit containerAdapter(const SERIAL<TYPE, ALLOC<TYPE>>& serial);
72
73 public:
80 [[nodiscard]] u_integer size() const override;
81
87 void clear();
88
96 bool contains(const TYPE &e) const override;
97
114 integer compareTo(const containerAdapter &other) const override;
115
121 [[nodiscard]] std::string className() const override;
122
129 [[nodiscard]] std::string toString(bool enter) const override;
130
132 ~containerAdapter() override = default;
133 };
134
135 template <typename TYPE,
136 template <typename, typename> typename SERIAL,
137 template <typename> typename ALLOC>
138 requires ExtendsOf<baseList<TYPE, ALLOC<TYPE>>, SERIAL<TYPE, ALLOC<TYPE>>>
141
142 template <typename TYPE,
143 template <typename, typename> typename SERIAL,
144 template <typename> typename ALLOC>
145 requires ExtendsOf<baseList<TYPE, ALLOC<TYPE>>, SERIAL<TYPE, ALLOC<TYPE>>>
147 {
148 return serial_.size();
149 }
150
151 template <typename TYPE,
152 template <typename, typename> typename SERIAL,
153 template <typename> typename ALLOC>
154 requires ExtendsOf<baseList<TYPE, ALLOC<TYPE>>, SERIAL<TYPE, ALLOC<TYPE>>>
156 serial_.clear();
157 }
158
159 template <typename TYPE,
160 template <typename, typename> typename SERIAL,
161 template <typename> typename ALLOC>
162 requires ExtendsOf<baseList<TYPE, ALLOC<TYPE>>, SERIAL<TYPE, ALLOC<TYPE>>>
163 auto containerAdapter<TYPE, SERIAL, ALLOC>::contains(const TYPE &e) const -> bool {
164 return serial_.contains(e);
165 }
166
167 template <typename TYPE,
168 template <typename, typename> typename SERIAL,
169 template <typename> typename ALLOC>
170 requires ExtendsOf<baseList<TYPE, ALLOC<TYPE>>, SERIAL<TYPE, ALLOC<TYPE>>>
172 {
173 return serial_.compareTo(other.serial_);
174 }
175
176 template <typename TYPE,
177 template <typename, typename> typename SERIAL,
178 template <typename> typename ALLOC>
179 requires ExtendsOf<baseList<TYPE, ALLOC<TYPE>>, SERIAL<TYPE, ALLOC<TYPE>>>
181 return "containerAdapter";
182 }
183
184 template <typename TYPE,
185 template <typename, typename> typename SERIAL,
186 template <typename> typename ALLOC>
187 requires ExtendsOf<baseList<TYPE, ALLOC<TYPE>>, SERIAL<TYPE, ALLOC<TYPE>>>
188 auto containerAdapter<TYPE, SERIAL, ALLOC>::toString(const bool enter) const -> std::string {
189 std::stringstream ss;
190 ss << this->className() << "(";
191 bool first = true;
192 for (const auto e : this->serial_)
193 {
194 if (!first) ss << ", ";
196 first = false;
197 }
198 ss << ")";
199 if (enter) ss << "\n";
200 return ss.str();
201 }
202}
203
204#endif //CONTAINERADAPTER_H
Provides a base class for variable-size serial containers.
Base class for comparable objects.
Definition comparable.h:31
SERIAL< TYPE, ALLOC< TYPE > > serial_
The underlying container instance.
Definition containerAdapter.h:60
u_integer size() const override
Returns the number of elements in the adapter.
Definition containerAdapter.h:146
containerAdapter(const SERIAL< TYPE, ALLOC< TYPE > > &serial)
Constructs a container adapter with specified underlying container.
Definition containerAdapter.h:139
void clear()
Removes all elements from the adapter.
Definition containerAdapter.h:155
std::string toString(bool enter) const override
Generates formatted string representation.
Definition containerAdapter.h:188
~containerAdapter() override=default
Virtual destructor for proper polymorphic cleanup.
integer compareTo(const containerAdapter &other) const override
Compares two container adapters lexicographically.
Definition containerAdapter.h:171
bool contains(const TYPE &e) const override
Checks for element existence in the adapter.
Definition containerAdapter.h:163
std::string className() const override
Gets class name identifier for type information.
Definition containerAdapter.h:180
container(ALLOC alloc=ALLOC{})
Definition container.h:129
Base class providing polymorphic string conversion capabilities.
Definition printable.h:25
static std::string formatString(const TYPE &t)
Universal value-to-string conversion.
Abstract base class for sequential containers with index-based access.
Definition serial.h:34
Interface for objects that can be compared.
Checks derivation or type identity.
Definition types.h:157
Main namespace for the project Original.
Definition algorithms.h:21
std::uint32_t u_integer
32-bit unsigned integer type for sizes/indexes
Definition config.h:17
std::int64_t integer
64-bit signed integer type for arithmetic operations
Definition config.h:15
Interface for polymorphic string formatting and output.
Type system foundations and concept definitions.