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
Classes | Typedefs | Enumerations | Functions
StormByte::Buffer Namespace Reference

Namespace for buffer-related components in the StormByte library. More...

Classes

class  BufferNotReady
 Exception class for buffer readiness errors. More...
 
class  BufferOverflow
 Exception class for buffer overflow errors. More...
 
class  Consumer
 A read-only interface for accessing a shared buffer. More...
 
class  Exception
 Base exception class for buffer-related errors. More...
 
class  External
 A specialized buffer that extends the functionality of the Shared buffer by integrating an external Reader class. More...
 
class  Pipeline
 A class designed to execute a sequence of functions asynchronously in a pipeline. More...
 
class  Producer
 A write-only interface for accessing a shared buffer. More...
 
class  Reader
 Abstract base class for implementing external data readers. More...
 
class  Shared
 A thread-safe version of the Simple buffer. More...
 
class  Simple
 A lightweight class for storing and manipulating simple byte buffers. More...
 

Typedefs

using Byte = std::byte
 Represents a single byte of data.
 
using Data = std::vector< Byte >
 Represents collection of bytes stored in the buffer.
 
using ByteSpan = std::span< Byte >
 Represents a span of bytes.
 
using ConstByteSpan = std::span< const Byte >
 Represents a constant span of bytes.
 
template<class T >
using ExpectedByte = Expected< Byte, T >
 Represents a single byte with error handling.
 
template<class T >
using ExpectedByteRef = Expected< Byte &, T >
 Represents a reference to a single byte with error handling.
 
template<class T >
using ExpectedByteSpan = Expected< ByteSpan, T >
 Represents a span of bytes with error handling.
 
template<class T >
using ExpectedConstByte = Expected< const Byte, T >
 Represents a constant byte with error handling.
 
template<class T >
using ExpectedConstByteRef = Expected< const Byte &, T >
 Represents a reference to a constant byte with error handling.
 
template<class T >
using ExpectedConstByteSpan = Expected< std::span< const Byte >, T >
 Represents a constant span of bytes with error handling.
 
template<class T >
using ExpectedData = Expected< Data, T >
 Represents a collection of bytes with error handling.
 
using PipeFunction = std::function< void(Consumer, Producer)>
 Represents a function that processes a data pipe.
 
using Processor = std::function< std::shared_ptr< Simple >(const Simple &)>
 Represents a function that processes a buffer.
 

Enumerations

enum class  Status { Ready , ReadOnly , Error }
 Defines the status of the buffer during producer/consumer operations. More...
 

Functions

template<typename PtrType , typename T , typename = std::enable_if_t< (std::is_same_v<PtrType, std::shared_ptr<typename PtrType::element_type>> || std::is_same_v<PtrType, std::unique_ptr<typename PtrType::element_type>>) >>
PtrTypeoperator<< (PtrType &ptr, const T &value)
 Wrapper for operator<< to support std::shared_ptr or std::unique_ptr as the left-hand parameter.
 
template<typename PtrType , typename T , typename = std::enable_if_t< (std::is_same_v<PtrType, std::shared_ptr<typename PtrType::element_type>> || std::is_same_v<PtrType, std::unique_ptr<typename PtrType::element_type>>) >>
PtrTypeoperator<< (PtrType &ptr, T &&value)
 Wrapper for operator<< to support std::shared_ptr or std::unique_ptr as the left-hand parameter (move version).
 

Detailed Description

Namespace for buffer-related components in the StormByte library.

The Buffer namespace provides classes and utilities for managing various types of buffers in both single-threaded and multi-threaded environments. It supports a variety of use cases, including:

Enumeration Type Documentation

◆ Status

Defines the status of the buffer during producer/consumer operations.

The Status enumeration specifies the current state of the buffer.

Values:

  • Ready: The buffer is ready for operations.
  • EoF: The buffer has reached the end of the file/data.
  • Error: The buffer has encountered an error.
Enumerator
Ready 

Indicates the buffer is OK and ready for operations.

ReadOnly 

Indicates the buffer has closed its write end.

Error 

Indicates the buffer has encountered an error.

Function Documentation

◆ operator<<() [1/2]

template<typename PtrType , typename T , typename = std::enable_if_t< (std::is_same_v<PtrType, std::shared_ptr<typename PtrType::element_type>> || std::is_same_v<PtrType, std::unique_ptr<typename PtrType::element_type>>) >>
PtrType & StormByte::Buffer::operator<< ( PtrType ptr,
const T value 
)
inline

Wrapper for operator<< to support std::shared_ptr or std::unique_ptr as the left-hand parameter.

This template function allows appending data to instances of classes derived from Simple or Async when they are wrapped in smart pointers (std::shared_ptr or std::unique_ptr). It forwards the call to the existing operator<< implementation of the underlying object.

Template Parameters
PtrTypeThe type of the smart pointer (e.g., std::shared_ptr or std::unique_ptr).
TThe type of the value to append.
Parameters
ptrSmart pointer to an instance of a class derived from Simple or Async.
valueThe value to append to the buffer.
Returns
Reference to the updated smart pointer.
Note
If the smart pointer is null, the function does nothing and returns the original pointer.

◆ operator<<() [2/2]

template<typename PtrType , typename T , typename = std::enable_if_t< (std::is_same_v<PtrType, std::shared_ptr<typename PtrType::element_type>> || std::is_same_v<PtrType, std::unique_ptr<typename PtrType::element_type>>) >>
PtrType & StormByte::Buffer::operator<< ( PtrType ptr,
T &&  value 
)
inline

Wrapper for operator<< to support std::shared_ptr or std::unique_ptr as the left-hand parameter (move version).

This template function allows appending data to instances of classes derived from Simple or Async when they are wrapped in smart pointers (std::shared_ptr or std::unique_ptr). It forwards the call to the existing operator<< implementation of the underlying object, using move semantics.

Template Parameters
PtrTypeThe type of the smart pointer (e.g., std::shared_ptr or std::unique_ptr).
TThe type of the value to append.
Parameters
ptrSmart pointer to an instance of a class derived from Simple or Async.
valueThe value to append to the buffer.
Returns
Reference to the updated smart pointer.
Note
If the smart pointer is null, the function does nothing and returns the original pointer.