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
external.hxx
1#pragma once
2
3#include <StormByte/buffer/reader.hxx>
4#include <StormByte/buffer/shared.hxx>
5
19namespace StormByte::Buffer {
48 class STORMBYTE_PUBLIC External: public Shared {
49 public:
59 External(const Reader& reader) noexcept;
60
70 External(Reader&& reader) noexcept;
71
78 External(const External& other) = default;
79
86 External(External&& other) noexcept = default;
87
94 ~External() noexcept override = default;
95
103 External& operator=(const External& other) = default;
104
112 External& operator=(External&& other) noexcept = default;
113
122 External& operator<<(const Buffer::Status& status);
123
131 External& operator<<(const Simple& buffer);
132
140 External& operator<<(Simple&& buffer);
141
149 External& operator<<(const std::string& data);
150
158 External& operator<<(const Buffer::Data& data);
159
167 External& operator<<(Buffer::Data&& data);
168
178 template <typename NumericType, typename = std::enable_if_t<std::is_arithmetic_v<std::decay_t<NumericType>>>>
179 External& operator<<(const NumericType& value) {
180 Shared::operator<<(value);
181 return *this;
182 }
183
192
202 void Reader(const class Reader& reader) noexcept;
203
213 void Reader(class Reader&& reader) noexcept;
214
225 bool HasEnoughData(const std::size_t& length) override;
226
236 ExpectedData<BufferOverflow> Read(const size_t& length) const override;
237
238 private:
239 std::shared_ptr<class Reader> m_external_reader;
240
248 Read::Status Wait(const std::size_t& length) noexcept override;
249
258 bool ReadExternalData(const size_t& bytes) noexcept;
259 };
260}
A specialized buffer that extends the functionality of the Shared buffer by integrating an external R...
Definition external.hxx:48
External(Reader &&reader) noexcept
Constructs an External buffer taking ownership of a specified Reader instance.
External & operator>>(External &buffer)
Appends the current buffer's data to another buffer.
void Reader(const class Reader &reader) noexcept
Sets the external Reader instance.
~External() noexcept override=default
Destructor. Cleans up the buffer and releases any associated resources.
External(const External &other)=default
Copy constructor.
External(External &&other) noexcept=default
Move constructor.
bool HasEnoughData(const std::size_t &length) override
Checks if the buffer has enough data to satisfy a read request.
External(const Reader &reader) noexcept
Constructs an External buffer with a specified Reader instance.
void Reader(class Reader &&reader) noexcept
Sets the external Reader instance taking ownership of it.
ExpectedData< BufferOverflow > Read(const size_t &length) const override
Reads a specific size of data from the buffer.
Abstract base class for implementing external data readers.
Definition reader.hxx:37
A thread-safe version of the Simple buffer.
Definition shared.hxx:41
A lightweight class for storing and manipulating simple byte buffers.
Definition simple.hxx:36
Namespace for buffer-related components in the StormByte library.
Namespace for buffer-related components in the StormByte library.
Definition consumer.hxx:19
Expected< Data, T > ExpectedData
Represents a collection of bytes with error handling.
Definition typedefs.hxx:155
std::vector< Byte > Data
Represents collection of bytes stored in the buffer.
Definition typedefs.hxx:139
Status
Defines the status of the buffer during producer/consumer operations.
Definition typedefs.hxx:106