ORIGINAL
Loading...
Searching...
No Matches
original::iterationStream< TYPE, DERIVED > Class Template Reference

A stream class that allows iteration, comparison, and printing. More...

#include <iterationStream.h>

Inheritance diagram for original::iterationStream< TYPE, DERIVED >:
Inheritance graph
Collaboration diagram for original::iterationStream< TYPE, DERIVED >:
Collaboration graph

Public Member Functions

integer compareTo (const iterationStream &other) const override
 Compares the current iteration stream with another iteration stream.
 
std::string className () const override
 Returns the class name.
 
std::string toString (bool enter) const override
 Converts the iteration stream to a string representation.
 
- 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 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
 
- Public Member Functions inherited from original::iterable< TYPE >
iterAdaptor begin ()
 Returns an iterator pointing to the beginning of the iterable container.
 
iterAdaptor end ()
 Returns an iterator pointing to the end of the iterable container.
 
iterAdaptor begin () const
 Returns a constant iterator pointing to the beginning of the iterable container.
 
iterAdaptor end () const
 Returns a constant iterator pointing to the end of the iterable container.
 
iterAdaptor first ()
 Returns an iterator pointing to the first element.
 
iterAdaptor last ()
 Returns an iterator pointing to the last element.
 
iterAdaptor first () const
 Returns a constant iterator pointing to the first element.
 
iterAdaptor last () const
 Returns a constant iterator pointing to the last element.
 
virtual baseIterator< TYPE > * begins () const =0
 Returns the iterator to the beginning of the container.
 
virtual baseIterator< TYPE > * ends () const =0
 Returns the iterator to the end of the container.
 
template<typename Callback = transform<TYPE>>
requires Operation<Callback, TYPE>
void forEach (Callback operation=Callback{})
 Applies a given operation to each element in the iterable container.
 
template<typename Callback = transform<TYPE>>
requires Operation<Callback, TYPE>
void forEach (const Callback &operation=Callback{}) const
 Applies a given operation to each element in the iterable container (const version).
 
template<typename Callback>
requires original::Operation<Callback, TYPE>
auto forEach (Callback operation) -> void
 
template<typename Callback>
requires original::Operation<Callback, TYPE>
auto forEach (const Callback &operation) const -> void
 
- Public Member Functions inherited from original::comparable< iterationStream< TYPE, DERIVED > >
virtual integer compareTo (const DERIVED &other) const=0
 Compares the current object with another of the same type.
 
bool operator== (const DERIVED &other) const
 Checks if the current object is equal to another.
 
bool operator!= (const DERIVED &other) const
 Checks if the current object is not equal to another.
 
bool operator< (const DERIVED &other) const
 Checks if the current object is less than another.
 
bool operator> (const DERIVED &other) const
 Checks if the current object is greater than another.
 
bool operator<= (const DERIVED &other) const
 Checks if the current object is less than or equal to another.
 
bool operator>= (const DERIVED &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

std::string elementsString () const
 Returns a string representation of the elements in the stream.
 

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.
 
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
 

Detailed Description

template<typename TYPE, typename DERIVED>
class original::iterationStream< TYPE, DERIVED >

A stream class that allows iteration, comparison, and printing.

Template Parameters
TYPEThe type of elements contained in the stream.
DERIVEDThe derived class type.

This class allows iteration over a collection of elements of type TYPE. It provides methods for comparing two iteration streams and converting the stream into a string representation. The class is intended to be inherited by more specific stream types.

Member Function Documentation

◆ className()

template<typename TYPE, typename DERIVED>
auto original::iterationStream< TYPE, DERIVED >::className ( ) const
nodiscardoverridevirtual

Returns the class name.

This method returns a string representing the class name of the object.

Returns
The class name ("iterationStream").

Reimplemented from original::printable.

Reimplemented in original::vector< TYPE, ALLOC >, and original::vector< TYPE * >.

◆ compareTo()

template<typename TYPE, typename DERIVED>
auto original::iterationStream< TYPE, DERIVED >::compareTo ( const iterationStream< TYPE, DERIVED > & other) const
override

Compares the current iteration stream with another iteration stream.

Parameters
otherAnother iteration stream to compare with.

Compares the elements of the two streams sequentially. If the elements are equal, the comparison continues. The first unequal element determines the result.

Returns
A value indicating the comparison result: -1 if the current stream is less than the other, 1 if greater, and 0 if equal.

◆ elementsString()

template<typename TYPE, typename DERIVED>
auto original::iterationStream< TYPE, DERIVED >::elementsString ( ) const
nodiscardprotected

Returns a string representation of the elements in the stream.

This method iterates over the elements and formats them into a string.

Returns
A string that lists all elements in the stream.

◆ toString()

template<typename TYPE, typename DERIVED>
auto original::iterationStream< TYPE, DERIVED >::toString ( bool enter) const
nodiscardoverridevirtual

Converts the iteration stream to a string representation.

Parameters
enterWhether to add a newline at the end of the string.

This method returns a string containing the class name followed by a string representation of the stream elements. An optional newline character can be appended based on the enter parameter.

Returns
A string representation of the stream.

Reimplemented from original::printable.


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