ORIGINAL
|
Adapter class that provides unified interface for various container types. More...
#include <containerAdapter.h>
Public Member Functions | |
u_integer | size () const override |
Returns the number of elements in the adapter. | |
void | clear () |
Removes all elements from the adapter. | |
bool | contains (const TYPE &e) const override |
Checks for element existence in the adapter. | |
integer | compareTo (const containerAdapter &other) const override |
Compares two container adapters lexicographically. | |
std::string | className () const override |
Gets class name identifier for type information. | |
std::string | toString (bool enter) const override |
Generates formatted string representation. | |
~containerAdapter () override=default | |
Virtual destructor for proper polymorphic cleanup. | |
![]() | |
operator std::string () const | |
Explicit conversion to std::string. | |
operator const char * () const | |
Explicit conversion to C-style string. | |
const char * | toCString (bool enter) const |
Direct C-string access with formatting control. | |
template<typename TYPE> | |
auto | formatString (const TYPE &t) -> std::string |
template<typename TYPE> | |
auto | formatCString (const TYPE &t) -> const char * |
template<typename TYPE> | |
auto | formatEnum (const TYPE &t) -> std::string |
template<typename TYPE> | |
auto | formatString (TYPE *const &ptr) -> std::string |
![]() | |
bool | empty () const |
Checks if the container is empty. | |
virtual | ~container ()=default |
Destructor for the container class. | |
![]() | |
bool | operator== (const containerAdapter< TYPE, SERIAL, ALLOC > &other) const |
Checks if the current object is equal to another. | |
bool | operator!= (const containerAdapter< TYPE, SERIAL, ALLOC > &other) const |
Checks if the current object is not equal to another. | |
bool | operator< (const containerAdapter< TYPE, SERIAL, ALLOC > &other) const |
Checks if the current object is less than another. | |
bool | operator> (const containerAdapter< TYPE, SERIAL, ALLOC > &other) const |
Checks if the current object is greater than another. | |
bool | operator<= (const containerAdapter< TYPE, SERIAL, ALLOC > &other) const |
Checks if the current object is less than or equal to another. | |
bool | operator>= (const containerAdapter< TYPE, SERIAL, ALLOC > &other) const |
Checks if the current object is greater than or equal to another. | |
virtual | ~comparable ()=default |
Virtual destructor for proper cleanup of derived objects. | |
Protected Member Functions | |
containerAdapter (const SERIAL< TYPE, ALLOC< TYPE > > &serial) | |
Constructs a container adapter with specified underlying container. | |
![]() | |
container (ALLOC alloc=ALLOC{}) | |
Constructs a container with specified allocator. | |
TYPE * | allocate (u_integer size) |
Allocates raw memory for elements. | |
void | deallocate (TYPE *ptr, u_integer size) |
Deallocates memory previously allocated by allocate() | |
void | construct (O_TYPE *o_ptr, Args &&... args) |
Constructs an element in-place. | |
void | destroy (O_TYPE *o_ptr) |
Destroys an element. | |
Protected Attributes | |
SERIAL< TYPE, ALLOC< TYPE > > | serial_ |
The underlying container instance. | |
![]() | |
ALLOC | allocator |
The allocator instance used for memory management. | |
Additional Inherited Members | |
![]() | |
template<typename TYPE> | |
static std::string | formatString (const TYPE &t) |
Universal value-to-string conversion. | |
template<typename TYPE> | |
static std::string | formatString (TYPE *const &ptr) |
Pointer-specific formatting. | |
template<typename TYPE> | |
static const char * | formatCString (const TYPE &t) |
C-string cache for temporary usage. | |
template<typename TYPE> | |
static std::string | formatEnum (const TYPE &t) |
Enum formatting utility. | |
template<> | |
auto | formatString (const char &t) -> std::string |
template<> | |
auto | formatString (const bool &t) -> std::string |
template<> | |
auto | formatString (const char *const &ptr) -> std::string |
Adapter class that provides unified interface for various container types.
TYPE | The type of elements stored in the container |
SERIAL | The underlying serial container type |
ALLOC | The allocator template to use for memory management |
This class template adapts different serial container types (like vectors, lists) to provide consistent interfaces including size checking, element existence verification, and formatted string output. Inherits both printable interface and container interface.
The allocator template is propagated to both the base container class and the underlying serial container for consistent memory management. The adapter provides full comparison support through the comparable interface, with lexicographical ordering based on the underlying container's elements. All comparison operations (==, !=, <, >, <=, >=) are available.
SERIAL | Must satisfy: ExtendsOf<baseList<TYPE, ALLOC<TYPE>>, SERIAL<TYPE, ALLOC<TYPE>>>
|
|
explicitprotected |
Constructs a container adapter with specified underlying container.
serial | The underlying container instance to adapt |
The constructor initializes the adapter with the provided serial container. The allocator from the serial container will be used for all memory operations.
|
nodiscardoverridevirtual |
Gets class name identifier for type information.
Reimplemented from original::printable.
Reimplemented in original::deque< TYPE, SERIAL, ALLOC >, original::prique< TYPE, Callback, SERIAL, ALLOC >, original::queue< TYPE, SERIAL, ALLOC >, and original::stack< TYPE, SERIAL, ALLOC >.
auto original::containerAdapter< TYPE, SERIAL, ALLOC >::clear | ( | ) |
Removes all elements from the adapter.
Clears content through underlying container's clear() method. All elements are properly destroyed using the container's allocator.
|
overridevirtual |
Compares two container adapters lexicographically.
other | The container adapter to compare against |
The comparison is performed by delegating to the underlying serial container's compareTo method. This provides lexicographical comparison of elements in the containers, similar to standard container comparison semantics.
The comparison follows these rules:
Implements original::comparable< containerAdapter< TYPE, SERIAL, ALLOC > >.
|
overridevirtual |
Checks for element existence in the adapter.
e | Element to search for |
Uses underlying container's contains() method for verification. The search operation respects the memory layout determined by the allocator.
Implements original::container< TYPE, ALLOC< TYPE > >.
|
nodiscardoverridevirtual |
Returns the number of elements in the adapter.
Directly delegates to underlying container's size() method. Memory usage depends on the underlying container's allocator.
Implements original::container< TYPE, ALLOC< TYPE > >.
|
nodiscardoverridevirtual |
Generates formatted string representation.
enter | Add newline at end when true |
Provides uniform formatting across all container adapters
Reimplemented from original::printable.
|
protected |
The underlying container instance.
Holds the actual container elements and manages memory using the provided allocator. All operations are delegated to this container instance.