ORIGINAL
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Friends | List of all members
original::iterable< TYPE >::iterAdaptor Class Referencefinal

RAII wrapper for base iterators that provides standard iteration interface. More...

#include <iterable.h>

Inheritance diagram for original::iterable< TYPE >::iterAdaptor:
Inheritance graph
Collaboration diagram for original::iterable< TYPE >::iterAdaptor:
Collaboration graph

Public Member Functions

 iterAdaptor (const iterAdaptor &other)
 Copy constructor for the iterAdaptor.
 
iterAdaptoroperator= (const iterAdaptor &other)
 Copy assignment operator for the iterAdaptor.
 
const iterator< TYPE > & getIt () const
 Gets the underlying iterator.
 
bool hasNext () const override
 Checks if there is a next element.
 
bool hasPrev () const override
 Checks if there is a previous element.
 
bool atPrev (const iterator< TYPE > *other) const override
 Checks if the current iterator is at the previous element relative to another iterator.
 
bool atNext (const iterator< TYPE > *other) const override
 Checks if the current iterator is at the next element relative to another iterator.
 
void next () const override
 Moves the iterator to the next element.
 
void prev () const override
 Moves the iterator to the previous element.
 
void operator+= (integer steps) const override
 Advances the iterator by a specified number of steps.
 
void operator-= (integer steps) const override
 Moves the iterator backward by a specified number of steps.
 
integer operator- (const iterator< TYPE > &other) const override
 Calculates the distance between this iterator and another iterator.
 
TYPEget () override
 Gets the value of the element the iterator is pointing to.
 
void set (const TYPE &data) override
 Sets the value of the element the iterator is pointing to.
 
TYPE get () const override
 Gets the value of the element the iterator is pointing to (const version).
 
bool isValid () const override
 Checks if the iterator is pointing to a valid element.
 
std::string className () const override
 Returns the class name.
 
std::string toString (bool enter) const override
 Converts the iterator to a string representation.
 
 ~iterAdaptor () override
 Destructor for iterAdaptor.
 
- Public Member Functions inherited from original::iterator< TYPE >
TYPEoperator* ()
 Dereferences the iterator to get the element.
 
TYPE operator* () const
 Dereferences the iterator to get a copy of the element.
 
void operator++ () const
 Moves the iterator forward by one position.
 
void operator++ (int postfix) const
 Moves the iterator forward by one position (postfix).
 
void operator-- () const
 Moves the iterator backward by one position.
 
void operator-- (int postfix) const
 Moves the iterator backward by one position (postfix).
 
integer compareTo (const iterator &other) const override
 Compares two iterators to determine their relative positions.
 
 operator bool () const
 Checks if the iterator is valid (i.e., points to a valid element).
 
bool atPrev (const iterator &other) const
 Checks if this iterator is positioned at the previous element.
 
bool atNext (const iterator &other) const
 Checks if this iterator is positioned at the next element.
 
virtual TYPE getElem () const
 Returns a copy of the element.
 
bool equal (const iterator *other) const
 Checks if two iterators are equal.
 
bool equal (const iterator &other) const
 Checks if two iterators are equal.
 
std::string className () const override
 Returns the class name of the iterator.
 
std::string toString (bool enter) const override
 Returns a string representation of the iterator.
 
 ~iterator () override=default
 Virtual destructor for proper cleanup of derived objects.
 
- Public Member Functions inherited from original::printable
 operator std::string () const
 Explicit conversion to std::string.
 
 operator const char * () const
 Explicit conversion to C-style string.
 
const chartoCString (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
 
- Public Member Functions inherited from original::cloneable
 ~cloneable () override=default
 Virtual destructor for cloneable.
 
- Public Member Functions inherited from original::baseCloneable< cloneable >
virtual ~baseCloneable ()=default
 Virtual destructor for baseCloneable.
 
- Public Member Functions inherited from original::comparable< iterator< TYPE > >
bool operator== (const iterator< TYPE > &other) const
 Checks if the current object is equal to another.
 
bool operator!= (const iterator< TYPE > &other) const
 Checks if the current object is not equal to another.
 
bool operator< (const iterator< TYPE > &other) const
 Checks if the current object is less than another.
 
bool operator> (const iterator< TYPE > &other) const
 Checks if the current object is greater than another.
 
bool operator<= (const iterator< TYPE > &other) const
 Checks if the current object is less than or equal to another.
 
bool operator>= (const iterator< TYPE > &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

bool equalPtr (const iterator< TYPE > *other) const override
 Compares the current iterator with another iterator.
 
iterAdaptorclone () const override
 Creates a copy of the current iterator.
 
iterAdaptorgetPrev () const override
 Gets the previous iterator.
 
iterAdaptorgetNext () const override
 Gets the next iterator.
 
- Protected Member Functions inherited from original::cloneable
 cloneable ()=default
 Default constructor for cloneable.
 
- Protected Member Functions inherited from original::baseCloneable< cloneable >
 baseCloneable ()=default
 Default constructor for baseCloneable.
 

Friends

class iterable
 

Additional Inherited Members

- Static Public Member Functions inherited from original::printable
template<typename TYPE >
static std::string formatString (const TYPE &t)
 Universal value-to-string conversion with type-specific formatting.
 
template<Printable TYPE>
static std::string formatString (const TYPE &t)
 Specialization for types deriving from printable.
 
template<EnumType TYPE>
static std::string formatString (const TYPE &t)
 Specialization for enum types with type-safe formatting.
 
template<typename TYPE >
static std::string formatString (TYPE *const &ptr)
 Pointer-specific formatting with null safety.
 
template<typename TYPE >
static const charformatCString (const TYPE &t)
 C-string cache for temporary usage with static storage.
 
template<typename TYPE >
static std::string formatEnum (const TYPE &t)
 Enum formatting utility with underlying value extraction.
 
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
 

Detailed Description

template<typename TYPE>
class original::iterable< TYPE >::iterAdaptor

RAII wrapper for base iterators that provides standard iteration interface.

This adapter:

The adapter ensures proper cleanup when destroyed and provides a unified interface regardless of the underlying iterator implementation.

Constructor & Destructor Documentation

◆ iterAdaptor()

template<typename TYPE >
original::iterable< TYPE >::iterAdaptor::iterAdaptor ( const iterAdaptor other)

Copy constructor for the iterAdaptor.

Parameters
otherThe iterAdaptor to copy.

Performs deep copy of the underlying iterator.

◆ ~iterAdaptor()

template<typename TYPE >
original::iterable< TYPE >::iterAdaptor::~iterAdaptor ( )
override

Destructor for iterAdaptor.

Deletes the underlying base iterator, ensuring proper cleanup.

Member Function Documentation

◆ atNext()

template<typename TYPE >
auto original::iterable< TYPE >::iterAdaptor::atNext ( const iterator< TYPE > *  other) const
overridevirtual

Checks if the current iterator is at the next element relative to another iterator.

Parameters
otherThe iterator to compare with.
Returns
true if this iterator is positioned just after the other iterator.

Performs dynamic type checking and delegates to underlying iterator.

Implements original::iterator< TYPE >.

◆ atPrev()

template<typename TYPE >
auto original::iterable< TYPE >::iterAdaptor::atPrev ( const iterator< TYPE > *  other) const
overridevirtual

Checks if the current iterator is at the previous element relative to another iterator.

Parameters
otherThe iterator to compare with.
Returns
true if this iterator is positioned just before the other iterator.

Performs dynamic type checking and delegates to underlying iterator.

Implements original::iterator< TYPE >.

◆ className()

template<typename TYPE >
auto original::iterable< TYPE >::iterAdaptor::className ( ) const
overridevirtual

Returns the class name.

Returns
The string "iterAdaptor".

Reimplemented from original::printable.

◆ clone()

template<typename TYPE >
auto original::iterable< TYPE >::iterAdaptor::clone ( ) const
overrideprotectedvirtual

Creates a copy of the current iterator.

Returns
A new iterAdaptor pointing to the same element as the current iterator.
Exceptions
std::bad_allocif memory allocation fails

Implements original::iterator< TYPE >.

◆ equalPtr()

template<typename TYPE >
auto original::iterable< TYPE >::iterAdaptor::equalPtr ( const iterator< TYPE > *  other) const
overrideprotectedvirtual

Compares the current iterator with another iterator.

Parameters
otherThe iterator to compare with.
Returns
true if the iterators are pointing to the same element.

Performs dynamic type checking and delegates to underlying iterator.

Implements original::iterator< TYPE >.

◆ get() [1/2]

template<typename TYPE >
auto original::iterable< TYPE >::iterAdaptor::get ( ) const
overridevirtual

Gets the value of the element the iterator is pointing to (const version).

Returns
The element value.
Exceptions
invalidIteratorErrorif iterator is not valid

Implements original::iterator< TYPE >.

◆ get() [2/2]

template<typename TYPE >
auto original::iterable< TYPE >::iterAdaptor::get ( )
overridevirtual

Gets the value of the element the iterator is pointing to.

Returns
A reference to the element.
Exceptions
invalidIteratorErrorif iterator is not valid

Implements original::iterator< TYPE >.

◆ getIt()

template<typename TYPE >
auto original::iterable< TYPE >::iterAdaptor::getIt ( ) const

Gets the underlying iterator.

Returns
A reference to the underlying base iterator.

◆ getNext()

template<typename TYPE >
auto original::iterable< TYPE >::iterAdaptor::getNext ( ) const
overrideprotectedvirtual

Gets the next iterator.

Returns
A new iterAdaptor pointing to the next element.
Exceptions
std::bad_allocif memory allocation fails
Note
This creates a new iterator instance, does not modify the current one.

Reimplemented from original::iterator< TYPE >.

◆ getPrev()

template<typename TYPE >
auto original::iterable< TYPE >::iterAdaptor::getPrev ( ) const
overrideprotectedvirtual

Gets the previous iterator.

Returns
A new iterAdaptor pointing to the previous element.
Exceptions
std::bad_allocif memory allocation fails
Note
This creates a new iterator instance, does not modify the current one.

Implements original::iterator< TYPE >.

◆ hasNext()

template<typename TYPE >
auto original::iterable< TYPE >::iterAdaptor::hasNext ( ) const
overridevirtual

Checks if there is a next element.

Returns
true if there is a next element.

Delegates to the underlying iterator's hasNext() method.

Implements original::iterator< TYPE >.

◆ hasPrev()

template<typename TYPE >
auto original::iterable< TYPE >::iterAdaptor::hasPrev ( ) const
overridevirtual

Checks if there is a previous element.

Returns
true if there is a previous element.

Delegates to the underlying iterator's hasPrev() method.

Implements original::iterator< TYPE >.

◆ isValid()

template<typename TYPE >
bool original::iterable< TYPE >::iterAdaptor::isValid ( ) const
overridevirtual

Checks if the iterator is pointing to a valid element.

Returns
true if the iterator is valid, false otherwise.

Delegates to the underlying iterator's isValid() method.

Implements original::iterator< TYPE >.

◆ next()

template<typename TYPE >
auto original::iterable< TYPE >::iterAdaptor::next ( ) const
overridevirtual

Moves the iterator to the next element.

Delegates to the underlying iterator's next() method.

Warning
Invalidates any previous references to the current element.

Implements original::iterator< TYPE >.

◆ operator+=()

template<typename TYPE >
auto original::iterable< TYPE >::iterAdaptor::operator+= ( integer  steps) const
overridevirtual

Advances the iterator by a specified number of steps.

Parameters
stepsThe number of steps to move forward.

Delegates to the underlying iterator's operator+= method.

Exceptions
outOfBoundErrorif stepping beyond container boundaries

Implements original::iterator< TYPE >.

◆ operator-()

template<typename TYPE >
auto original::iterable< TYPE >::iterAdaptor::operator- ( const iterator< TYPE > &  other) const
overridevirtual

Calculates the distance between this iterator and another iterator.

Parameters
otherThe iterator to compare with.
Returns
The number of steps between the two iterators.

Positive if this iterator is after the other, negative if before. Delegates to the underlying iterator's distance calculation.

Implements original::iterator< TYPE >.

◆ operator-=()

template<typename TYPE >
auto original::iterable< TYPE >::iterAdaptor::operator-= ( integer  steps) const
overridevirtual

Moves the iterator backward by a specified number of steps.

Parameters
stepsThe number of steps to move backward.

Delegates to the underlying iterator's operator-= method.

Exceptions
outOfBoundErrorif stepping beyond container boundaries

Implements original::iterator< TYPE >.

◆ operator=()

template<typename TYPE >
auto original::iterable< TYPE >::iterAdaptor::operator= ( const iterAdaptor other)

Copy assignment operator for the iterAdaptor.

Parameters
otherThe iterAdaptor to copy.
Returns
A reference to the current iterAdaptor.

Performs deep copy and properly handles self-assignment.

◆ prev()

template<typename TYPE >
auto original::iterable< TYPE >::iterAdaptor::prev ( ) const
overridevirtual

Moves the iterator to the previous element.

Delegates to the underlying iterator's prev() method.

Warning
Invalidates any previous references to the current element.

Implements original::iterator< TYPE >.

◆ set()

template<typename TYPE >
auto original::iterable< TYPE >::iterAdaptor::set ( const TYPE data)
overridevirtual

Sets the value of the element the iterator is pointing to.

Parameters
dataThe value to set.
Exceptions
invalidIteratorErrorif iterator is not valid

Implements original::iterator< TYPE >.

◆ toString()

template<typename TYPE >
auto original::iterable< TYPE >::iterAdaptor::toString ( bool  enter) const
overridevirtual

Converts the iterator to a string representation.

Parameters
enterIf true, adds a newline at the end.
Returns
A string representation of the iterator.

Includes the class name and the underlying iterator's string representation.

Reimplemented from original::printable.


The documentation for this class was generated from the following file: