Sese Framework
2.3.0
A cross-platform framework
|
Byte buffer class. More...
#include <AbstractByteBuffer.h>
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 |
Node * | root = nullptr |
Node * | currentWriteNode = nullptr |
size_t | currentWritePos = 0 |
Node * | currentReadNode = 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< Stream > | Ptr |
Public Types inherited from sese::io::InputStream | |
typedef std::shared_ptr< InputStream > | Ptr |
Public Types inherited from sese::io::OutputStream | |
typedef std::shared_ptr< OutputStream > | Ptr |
Public Types inherited from sese::io::PeekableStream | |
typedef std::shared_ptr< PeekableStream > | Ptr |
Byte buffer class.
|
explicit |
base_size | Initial node memory size |
factor | Size of additional memory nodes |
References cap, currentReadNode, currentWriteNode, factor, and root.
|
noexcept |
|
noexcept |
Mobile semantics.
References cap, currentReadNode, currentReadPos, currentWriteNode, currentWritePos, factor, length, sese::io::AbstractByteBuffer::Node::length, and root.
|
override |
References sese::io::AbstractByteBuffer::Node::next, and root.
|
virtual |
Whether there is readable data.
Reimplemented in sese::io::ByteBuffer.
References currentReadNode, currentReadPos, sese::io::AbstractByteBuffer::Node::length, and sese::io::AbstractByteBuffer::Node::next.
Referenced by sese::io::ByteBuffer::eof().
|
virtual |
Release all nodes before CurrentReadNode
Reimplemented in sese::io::ByteBuffer.
References sese::io::AbstractByteBuffer::Node::cap, currentReadNode, currentReadPos, currentWriteNode, currentWritePos, sese::io::AbstractByteBuffer::Node::length, sese::io::AbstractByteBuffer::Node::next, and root.
Referenced by sese::io::ByteBuffer::freeCapacity().
|
nodiscardvirtual |
Reimplemented in sese::io::ByteBuffer.
References cap.
Referenced by sese::io::ByteBuffer::getCapacity().
|
nodiscardvirtual |
Reimplemented in sese::io::ByteBuffer.
References currentWriteNode, length, and sese::io::AbstractByteBuffer::Node::length.
Referenced by sese::io::ByteBuffer::getLength(), and sese::internal::net::http::HttpClientImpl::request().
|
nodiscardvirtual |
References sese::io::AbstractByteBuffer::Node::cap, currentReadNode, currentReadPos, currentWriteNode, currentWritePos, sese::io::AbstractByteBuffer::Node::length, and sese::io::AbstractByteBuffer::Node::next.
|
overridevirtual |
Read content without stepping
buffer | Buffer |
length | Buffer size |
Implements sese::io::PeekableStream.
Reimplemented in sese::io::ByteBuffer.
References sese::io::AbstractByteBuffer::Node::buffer, currentReadNode, currentReadPos, currentWriteNode, sese::io::AbstractByteBuffer::Node::length, and sese::io::AbstractByteBuffer::Node::next.
Referenced by sese::service::TcpTransporter::onWrite(), sese::io::ByteBuffer::peek(), sese::iocp::v1::Context::peek(), sese::_windows::iocp::v1::NativeIOCPServer::postWrite(), sese::internal::net::http::HttpClientImpl::writeBodyByAuto(), and sese::internal::net::http::HttpClientImpl::writeHeader().
|
overridevirtual |
Implements sese::io::InputStream.
Reimplemented in sese::io::ByteBuffer.
References sese::io::AbstractByteBuffer::Node::buffer, currentReadNode, currentReadPos, currentWriteNode, sese::io::AbstractByteBuffer::Node::length, and sese::io::AbstractByteBuffer::Node::next.
Referenced by sese::MD5Util::encode(), sese::SHA1Util::encode(), sese::SHA256Util::encode(), sese::io::ByteBuffer::read(), and sese::iocp::v1::Context::read().
|
virtual |
Reset the read position.
Reimplemented in sese::io::ByteBuffer.
References currentReadNode, currentReadPos, and root.
Referenced by sese::io::ByteBuffer::resetPos(), and sese::internal::net::http::HttpClientImpl::writeHeader().
|
virtualnoexcept |
References cap, currentReadNode, currentReadPos, currentWriteNode, currentWritePos, length, and root.
|
overridevirtual |
Step only, without reading content
length | Step size |
Implements sese::io::PeekableStream.
Reimplemented in sese::io::ByteBuffer.
References currentReadNode, currentReadPos, currentWriteNode, sese::io::AbstractByteBuffer::Node::length, and sese::io::AbstractByteBuffer::Node::next.
Referenced by sese::io::ByteBuffer::trunc(), sese::iocp::v1::Context::trunc(), sese::internal::net::http::HttpClientImpl::writeBodyByAuto(), and sese::internal::net::http::HttpClientImpl::writeHeader().
|
overridevirtual |
Implements sese::io::OutputStream.
Reimplemented in sese::io::ByteBuffer.
References sese::io::AbstractByteBuffer::Node::buffer, cap, sese::io::AbstractByteBuffer::Node::cap, currentWriteNode, currentWritePos, factor, length, sese::io::AbstractByteBuffer::Node::length, and sese::io::AbstractByteBuffer::Node::next.
Referenced by sese::_windows::iocp::v1::NativeContext::write(), sese::io::ByteBuffer::write(), and sese::iocp::v1::Context::write().
|
private |
Referenced by AbstractByteBuffer(), AbstractByteBuffer(), getCapacity(), swap(), and write().
|
private |
Referenced by AbstractByteBuffer(), AbstractByteBuffer(), AbstractByteBuffer(), eof(), freeCapacity(), getReadableSize(), peek(), read(), resetPos(), swap(), and trunc().
|
private |
Referenced by AbstractByteBuffer(), eof(), freeCapacity(), getReadableSize(), peek(), read(), resetPos(), swap(), and trunc().
|
private |
Referenced by AbstractByteBuffer(), AbstractByteBuffer(), AbstractByteBuffer(), freeCapacity(), getLength(), getReadableSize(), peek(), read(), swap(), trunc(), and write().
|
private |
Referenced by AbstractByteBuffer(), freeCapacity(), getReadableSize(), swap(), and write().
|
private |
Referenced by AbstractByteBuffer(), AbstractByteBuffer(), and write().
|
private |
length does not count the last node, the real length should be: realLength = length + currentWriteNode->length
Referenced by AbstractByteBuffer(), getLength(), swap(), and write().
|
private |
Referenced by AbstractByteBuffer(), AbstractByteBuffer(), AbstractByteBuffer(), freeCapacity(), resetPos(), swap(), and ~AbstractByteBuffer().