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

Byte buffer class. More...

#include <AbstractByteBuffer.h>

Inheritance diagram for sese::io::AbstractByteBuffer:
sese::io::Stream sese::io::PeekableStream sese::io::InputStream sese::io::OutputStream sese::io::ByteBuffer sese::io::ByteBuilder

Classes

struct  Node
 Buffer node. More...
 

Public Member Functions

 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 void resetPos ()
 Reset the read position.
 
virtual bool eof ()
 Whether there is readable data.
 
virtual size_t getLength () const
 
virtual size_t getCapacity () const
 
virtual size_t getReadableSize () const
 
virtual size_t freeCapacity ()
 
virtual void swap (AbstractByteBuffer &other) noexcept
 
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
 
- Public Member Functions inherited from sese::io::InputStream
virtual ~InputStream () noexcept=default
 
- Public 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)
 
- Public Member Functions inherited from sese::io::PeekableStream
virtual ~PeekableStream ()=default
 

Private Attributes

size_t factor = 0
 
Noderoot = nullptr
 
NodecurrentWriteNode = nullptr
 
size_t currentWritePos = 0
 
NodecurrentReadNode = nullptr
 
size_t currentReadPos = 0
 
size_t length = 0
 
size_t cap = 0
 

Additional Inherited Members

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

Detailed Description

Byte buffer class.

Constructor & Destructor Documentation

◆ AbstractByteBuffer() [1/3]

sese::io::AbstractByteBuffer::AbstractByteBuffer ( size_t base_size = STREAM_BYTE_STREAM_SIZE_FACTOR,
size_t factor = STREAM_BYTE_STREAM_SIZE_FACTOR )
explicit
Parameters
base_sizeInitial node memory size
factorSize of additional memory nodes

References cap, currentReadNode, currentWriteNode, factor, and root.

◆ AbstractByteBuffer() [2/3]

◆ AbstractByteBuffer() [3/3]

sese::io::AbstractByteBuffer::AbstractByteBuffer ( AbstractByteBuffer && abstract_byte_buffer)
noexcept

◆ ~AbstractByteBuffer()

sese::io::AbstractByteBuffer::~AbstractByteBuffer ( )
override

Member Function Documentation

◆ eof()

bool sese::io::AbstractByteBuffer::eof ( )
virtual

◆ freeCapacity()

size_t sese::io::AbstractByteBuffer::freeCapacity ( )
virtual

◆ getCapacity()

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

Reimplemented in sese::io::ByteBuffer.

References cap.

Referenced by sese::io::ByteBuffer::getCapacity().

◆ getLength()

size_t sese::io::AbstractByteBuffer::getLength ( ) const
nodiscardvirtual

◆ getReadableSize()

size_t sese::io::AbstractByteBuffer::getReadableSize ( ) const
nodiscardvirtual

◆ peek()

◆ read()

◆ resetPos()

void sese::io::AbstractByteBuffer::resetPos ( )
virtual

◆ swap()

void sese::io::AbstractByteBuffer::swap ( AbstractByteBuffer & other)
virtualnoexcept

◆ trunc()

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

◆ write()

Member Data Documentation

◆ cap

size_t sese::io::AbstractByteBuffer::cap = 0
private

◆ currentReadNode

Node* sese::io::AbstractByteBuffer::currentReadNode = nullptr
private

◆ currentReadPos

size_t sese::io::AbstractByteBuffer::currentReadPos = 0
private

◆ currentWriteNode

Node* sese::io::AbstractByteBuffer::currentWriteNode = nullptr
private

◆ currentWritePos

size_t sese::io::AbstractByteBuffer::currentWritePos = 0
private

◆ factor

size_t sese::io::AbstractByteBuffer::factor = 0
private

◆ length

size_t sese::io::AbstractByteBuffer::length = 0
private

length does not count the last node, the real length should be: realLength = length + currentWriteNode->length

Referenced by AbstractByteBuffer(), getLength(), swap(), and write().

◆ root

Node* sese::io::AbstractByteBuffer::root = nullptr
private

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