Sese Framework  2.3.0
A cross-platform framework
Loading...
Searching...
No Matches
sese::io::ByteBuffer Class Referencefinal

Thread-safe byte buffer class. More...

#include <ByteBuffer.h>

Inheritance diagram for sese::io::ByteBuffer:
sese::io::AbstractByteBuffer

Public Types

using Ptr = std::unique_ptr<ByteBuffer>
 

Public Member Functions

 ByteBuffer (size_t base_size=STREAM_BYTE_STREAM_SIZE_FACTOR, size_t factor=STREAM_BYTE_STREAM_SIZE_FACTOR)
 
void resetPos () override
 Reset the read position.
 
bool eof () override
 Whether there is readable data.
 
size_t getLength ()
 
size_t getCapacity ()
 
size_t freeCapacity () override
 
int64_t read (void *buffer, size_t len) override
 
int64_t write (const void *buffer, size_t len) override
 
int64_t peek (void *buffer, size_t len) override
 
int64_t trunc (size_t need_read) override
 

Private Member Functions

virtual size_t getCapacity () const
 
virtual size_t getLength () const
 
- Private Member Functions inherited from sese::io::AbstractByteBuffer
 AbstractByteBuffer (size_t base_size=STREAM_BYTE_STREAM_SIZE_FACTOR, size_t factor=STREAM_BYTE_STREAM_SIZE_FACTOR)
 
 AbstractByteBuffer (const AbstractByteBuffer &abstract_byte_buffer) noexcept
 Copy.
 
 AbstractByteBuffer (AbstractByteBuffer &&abstract_byte_buffer) noexcept
 Mobile semantics.
 
 ~AbstractByteBuffer () override
 
virtual size_t getReadableSize () const
 
virtual void swap (AbstractByteBuffer &other) noexcept
 
- Private Member Functions inherited from sese::io::InputStream
virtual ~InputStream () noexcept=default
 
- Private Member Functions inherited from sese::io::OutputStream
virtual ~OutputStream () noexcept=default
 
int64_t write (const std::string_view &buffer)
 
int64_t write (const text::StringView &buffer)
 
template<typename T >
int64_t write (std::vector< T > &buffer)
 
template<typename T , size_t N>
int64_t write (std::array< T, N > &buffer)
 
- Private Member Functions inherited from sese::io::PeekableStream
virtual ~PeekableStream ()=default
 

Private Attributes

std::mutex mutex
 

Additional Inherited Members

- Private Types inherited from sese::io::Stream
typedef std::shared_ptr< StreamPtr
 
- Private Types inherited from sese::io::InputStream
typedef std::shared_ptr< InputStreamPtr
 
- Private Types inherited from sese::io::OutputStream
typedef std::shared_ptr< OutputStreamPtr
 
- Private Types inherited from sese::io::PeekableStream
typedef std::shared_ptr< PeekableStreamPtr
 

Detailed Description

Thread-safe byte buffer class.

Member Typedef Documentation

◆ Ptr

using sese::io::ByteBuffer::Ptr = std::unique_ptr<ByteBuffer>

Constructor & Destructor Documentation

◆ ByteBuffer()

sese::io::ByteBuffer::ByteBuffer ( size_t base_size = STREAM_BYTE_STREAM_SIZE_FACTOR,
size_t factor = STREAM_BYTE_STREAM_SIZE_FACTOR )
explicit

Member Function Documentation

◆ eof()

bool sese::io::ByteBuffer::eof ( )
overridevirtual

Whether there is readable data.

Reimplemented from sese::io::AbstractByteBuffer.

References sese::io::AbstractByteBuffer::eof().

◆ freeCapacity()

size_t sese::io::ByteBuffer::freeCapacity ( )
overridevirtual

Release all nodes before CurrentReadNode

Returns
Actual released space in bytes

Reimplemented from sese::io::AbstractByteBuffer.

References sese::io::AbstractByteBuffer::freeCapacity().

◆ getCapacity() [1/2]

size_t sese::io::ByteBuffer::getCapacity ( )
nodiscard

◆ getCapacity() [2/2]

size_t sese::io::AbstractByteBuffer::getCapacity ( ) const
nodiscardprivatevirtual
Returns
Total capacity of all nodes

Reimplemented from sese::io::AbstractByteBuffer.

◆ getLength() [1/2]

size_t sese::io::ByteBuffer::getLength ( )
nodiscard

◆ getLength() [2/2]

size_t sese::io::AbstractByteBuffer::getLength ( ) const
nodiscardprivatevirtual
Returns
Total memory used by all nodes

Reimplemented from sese::io::AbstractByteBuffer.

◆ peek()

int64_t sese::io::ByteBuffer::peek ( void * buffer,
size_t length )
overridevirtual

Read content without stepping

Parameters
bufferBuffer
lengthBuffer size
Returns
Actual size read

Reimplemented from sese::io::AbstractByteBuffer.

References sese::io::AbstractByteBuffer::peek().

◆ read()

int64_t sese::io::ByteBuffer::read ( void * buffer,
size_t len )
overridevirtual

◆ resetPos()

void sese::io::ByteBuffer::resetPos ( )
overridevirtual

Reset the read position.

Reimplemented from sese::io::AbstractByteBuffer.

References sese::io::AbstractByteBuffer::resetPos().

◆ trunc()

int64_t sese::io::ByteBuffer::trunc ( size_t length)
overridevirtual

Step only, without reading content

Parameters
lengthStep size
Returns
Actual step size

Reimplemented from sese::io::AbstractByteBuffer.

References sese::io::AbstractByteBuffer::trunc().

◆ write()

int64_t sese::io::ByteBuffer::write ( const void * buffer,
size_t len )
overridevirtual

Member Data Documentation

◆ mutex

std::mutex sese::io::ByteBuffer::mutex
private

Referenced by read().


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