StormByte C++ Library 0.0.9999
StormByte is a comprehensive, cross-platform C++ library aimed at easing system programming, configuration management, logging, and database handling tasks. This library provides a unified API that abstracts away the complexities and inconsistencies of different platforms (Windows, Linux).
Loading...
Searching...
No Matches
Public Member Functions | List of all members
StormByte::Buffer::Reader Class Referenceabstract

Abstract base class for implementing external data readers. More...

#include <reader.hxx>

Inheritance diagram for StormByte::Buffer::Reader:
Inheritance graph
[legend]
Collaboration diagram for StormByte::Buffer::Reader:
Collaboration graph
[legend]

Public Member Functions

 Reader () noexcept=default
 Default constructor.
 
 Reader (const Reader &other)=default
 Copy constructor.
 
 Reader (Reader &&other) noexcept=default
 Move constructor.
 
virtual ~Reader () noexcept=default
 Destructor.
 
Readeroperator= (const Reader &other)=default
 Copy assignment operator.
 
Readeroperator= (Reader &&other) noexcept=default
 Move assignment operator.
 
virtual Expected< Buffer::Simple, Buffer::ExceptionRead (const size_t &min=0) const noexcept=0
 Reads data from an external source.
 
- Public Member Functions inherited from StormByte::Clonable< Reader >
constexpr Clonable ()=default
 
constexpr Clonable (const Clonable &)=default
 
constexpr Clonable (Clonable &&) noexcept=default
 
constexpr Clonableoperator= (const Clonable &)=default
 
constexpr Clonableoperator= (Clonable &&) noexcept=default
 
virtual constexpr ~Clonable () noexcept=default
 
virtual PointerType Clone () const=0
 
virtual PointerType Move ()=0
 

Additional Inherited Members

- Public Types inherited from StormByte::Clonable< Reader >
using PointerType = std::shared_ptr< Reader >
 Pointer type.
 
- Static Public Member Functions inherited from StormByte::Clonable< Reader >
static PointerType MakePointer (Args &&... args)
 

Detailed Description

Abstract base class for implementing external data readers.

The Reader class provides an interface for reading external data into a buffer. It is designed to be used with the External buffer, enabling dynamic data retrieval from external sources such as files, network streams, or other producers.

Key Features:

This class is ideal for scenarios where data needs to be fetched dynamically from external sources and integrated into the External buffer.

Constructor & Destructor Documentation

◆ Reader() [1/3]

StormByte::Buffer::Reader::Reader ( )
defaultnoexcept

Default constructor.

Initializes a Reader instance. Derived classes should implement the Read() method to provide specific functionality for reading external data.

◆ Reader() [2/3]

StormByte::Buffer::Reader::Reader ( const Reader other)
default

Copy constructor.

Parameters
otherThe Reader instance to copy from.

◆ Reader() [3/3]

StormByte::Buffer::Reader::Reader ( Reader &&  other)
defaultnoexcept

Move constructor.

Parameters
otherThe Reader instance to move from.

◆ ~Reader()

virtual StormByte::Buffer::Reader::~Reader ( )
virtualdefaultnoexcept

Destructor.

Cleans up the Reader instance. Derived classes should ensure that any resources used for external data retrieval are properly released.

Member Function Documentation

◆ operator=() [1/2]

Reader & StormByte::Buffer::Reader::operator= ( const Reader other)
default

Copy assignment operator.

Parameters
otherThe Reader instance to copy from.
Returns
Reference to the updated Reader instance.

◆ operator=() [2/2]

Reader & StormByte::Buffer::Reader::operator= ( Reader &&  other)
defaultnoexcept

Move assignment operator.

Parameters
otherThe Reader instance to move from.
Returns
Reference to the updated Reader instance.

◆ Read()

virtual Expected< Buffer::Simple, Buffer::Exception > StormByte::Buffer::Reader::Read ( const size_t min = 0) const
pure virtualnoexcept

Reads data from an external source.

Parameters
minThe minimum number of bytes to read (0 to read any available bytes).
Returns
An Expected<Buffer::Simple, Buffer::Exception> containing the read data or an exception.

This method must be implemented by derived classes to provide functionality for reading data from an external source. The returned data is encapsulated in a Buffer::Simple object.

Behavior:

  • If data is successfully read, it should be returned as a Buffer::Simple object.
  • If an error occurs during the read operation, an Unexpected<Buffer::Exception> should be returned.
  • An empty buffer (i.e., a Buffer::Simple object with no data) is considered a valid response.

Error Handling:

  • Instead of throwing exceptions, this method uses Unexpected<Buffer::Exception> to signal errors.
  • The Buffer::Exception provides details about the error, such as the reason for failure.

Usage: This method is typically called by the External buffer to dynamically fetch or generate data before performing read operations.


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