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
consumer.hxx
1#pragma once
2
3#include <StormByte/buffer/shared.hxx>
4#include <memory>
5
18namespace StormByte::Buffer {
34 class STORMBYTE_PUBLIC Consumer final {
35 friend class Producer;
36
37 public:
43 Consumer(const Consumer& other) = default;
44
50 Consumer(Consumer&& other) noexcept = default;
51
57 ~Consumer() noexcept = default;
58
64 Consumer& operator=(const Consumer& other) = default;
65
71 Consumer& operator=(Consumer&& other) noexcept = default;
72
77 std::size_t AvailableBytes() const noexcept;
78
83 Buffer::Data Data() const noexcept;
84
90 void Discard(const std::size_t& length, const Read::Position& mode) noexcept;
91
96 bool End() const noexcept;
97
102 bool Empty() const noexcept;
103
109 ExpectedData<BufferOverflow> Extract(const size_t& length);
110
117 Read::Status ExtractInto(const size_t& length, Shared& output) noexcept;
118
124 bool HasEnoughData(const std::size_t& length) const;
125
131 std::string HexData(const std::size_t& column_size = 16) const;
132
137 bool IsEoF() const noexcept;
138
143 bool IsReadable() const noexcept;
144
149 ExpectedByte<BufferOverflow> Peek() const;
150
155 std::size_t Position() const noexcept;
156
162 ExpectedData<BufferOverflow> Read(const size_t& length) const;
163
169 void Seek(const std::ptrdiff_t& position, const Read::Position& mode) const;
170
175 std::size_t Size() const noexcept;
176
181 enum Status Status() const noexcept;
182
183 private:
184 std::shared_ptr<Shared> m_shared;
185
190 explicit Consumer(std::shared_ptr<Shared> shared) noexcept;
191
192
193 };
194}
Exception class for buffer overflow errors.
Definition exception.hxx:48
A read-only interface for accessing a shared buffer.
Definition consumer.hxx:34
~Consumer() noexcept=default
Destructor.
Consumer(const Consumer &other)=default
Deleted copy constructor.
Consumer(Consumer &&other) noexcept=default
Default move constructor.
A write-only interface for accessing a shared buffer.
Definition producer.hxx:40
A thread-safe version of the Simple buffer.
Definition shared.hxx:40
Namespace for buffer-related components in the StormByte library.
Namespace for read-related utilities in the StormByte library.