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
20 class Producer; // Forward declaration of the Producer class
21
37 class STORMBYTE_PUBLIC Consumer final {
38 friend class Producer;
39
40 public:
46 Consumer() noexcept;
47
52 explicit Consumer(std::shared_ptr<Shared> shared) noexcept;
53
59 Consumer(const Consumer& other) = default;
60
66 Consumer(Consumer&& other) noexcept = default;
67
73 ~Consumer() noexcept = default;
74
80 Consumer& operator=(const Consumer& other) = default;
81
87 Consumer& operator=(Consumer&& other) noexcept = default;
88
93 std::size_t AvailableBytes() const noexcept;
94
99 Buffer::Data Data() const noexcept;
100
106 void Discard(const std::size_t& length, const Read::Position& mode) noexcept;
107
112 bool End() const noexcept;
113
118 bool Empty() const noexcept;
119
125 ExpectedData<BufferOverflow> Extract(const size_t& length);
126
133 Read::Status ExtractInto(const size_t& length, Shared& output) noexcept;
134
140 bool HasEnoughData(const std::size_t& length) const;
141
147 std::string HexData(const std::size_t& column_size = 16) const;
148
153 bool IsEoF() const noexcept;
154
159 bool IsReadable() const noexcept;
160
166
171 std::size_t Position() const noexcept;
172
178 ExpectedData<BufferOverflow> Read(const size_t& length) const;
179
185 void Seek(const std::ptrdiff_t& position, const Read::Position& mode) const;
186
191 std::size_t Size() const noexcept;
192
197 enum Status Status() const noexcept;
198
203 Producer Producer() const noexcept;
204
205 private:
206 std::shared_ptr<Shared> m_shared;
207 };
208}
Exception class for buffer overflow errors.
Definition exception.hxx:48
A read-only interface for accessing a shared buffer.
Definition consumer.hxx:37
Consumer() noexcept
Default constructor.
A write-only interface for accessing a shared buffer.
Definition producer.hxx:43
A thread-safe version of the Simple buffer.
Definition shared.hxx:41
Namespace for buffer-related components in the StormByte library.
Namespace for read-related utilities in the StormByte library.
Namespace for buffer-related components in the StormByte library.
Definition consumer.hxx:19
Expected< Byte, T > ExpectedByte
Represents a single byte with error handling.
Definition typedefs.hxx:143
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