dodo
0.0.1
A C++ library to create containerized Linux services
|
Interface to read individual bytes whilst the implementation can read from an actual source (such as a network buffer) in larger chunks, reducing the number of required system calls. More...
#include <socketreadbuffer.hpp>
Public Member Functions | |
virtual char | get () const =0 |
Get the current char from VirtualReadBuffer. More... | |
size_t | getUnderflowCount () const |
Return the number of times underflow() was invoked. More... | |
virtual common::SystemError | next ()=0 |
Move to the next char from the VirtualReadBuffer. More... | |
virtual common::SystemError | underflow ()=0 |
If the buffer_ underflows, the buffer_ must be reset refilledwith new data from the source. More... | |
Protected Attributes | |
char * | buffer_ |
The buffer. More... | |
ssize_t | bufsize_ |
The size of buffer_. More... | |
size_t | underflows_ |
The number underflow() invocations. More... | |
Interface to read individual bytes whilst the implementation can read from an actual source (such as a network buffer) in larger chunks, reducing the number of required system calls.
This is covenient when implementing protocols that need be char (byte) scanned to parse.
Note that this interface requires a source that blocks on read. A call to next() will advance the current byte, but this in turn will call underflow, which in turn might do a read if it reached the end of available bytes.
Definition at line 44 of file socketreadbuffer.hpp.
|
pure virtual |
Get the current char from VirtualReadBuffer.
Implemented in dodo::network::StringReadBuffer, dodo::network::FileReadBuffer, and dodo::network::SocketReadBuffer.
Referenced by dodo::network::protocol::http::HTTPMessage::eatCRLF(), dodo::network::protocol::http::HTTPMessage::eatSpace(), dodo::network::protocol::http::HTTPVersion::parse(), dodo::network::protocol::http::HTTPRequest::HTTPRequestLine::parse(), dodo::network::protocol::http::HTTPRequest::parse(), dodo::network::protocol::http::HTTPResponse::HTTPResponseLine::parse(), dodo::network::protocol::http::HTTPResponse::parse(), dodo::network::protocol::http::HTTPRequest::parseBody(), dodo::network::protocol::http::HTTPResponse::parseBody(), dodo::network::protocol::http::HTTPMessage::parseChunkedBody(), dodo::network::protocol::http::HTTPMessage::parseChunkHex(), dodo::network::protocol::http::HTTPMessage::parseCRLF(), dodo::network::protocol::http::HTTPMessage::parseFieldValue(), dodo::network::protocol::http::HTTPMessage::parseHeaders(), dodo::network::protocol::http::HTTPMessage::parseToken(), and dodo::network::protocol::http::HTTPMessage::parseUInt().
|
inline |
Return the number of times underflow() was invoked.
Definition at line 73 of file socketreadbuffer.hpp.
References underflows_.
|
pure virtual |
Move to the next char from the VirtualReadBuffer.
Note that call will return a SystemError::ecEAGAIN if there is no more data (received within the prevailing timeout).
Implemented in dodo::network::StringReadBuffer, dodo::network::FileReadBuffer, and dodo::network::SocketReadBuffer.
Referenced by dodo::network::protocol::http::HTTPMessage::eatCRLF(), dodo::network::protocol::http::HTTPMessage::eatSpace(), dodo::network::protocol::http::HTTPVersion::parse(), dodo::network::protocol::http::HTTPRequest::HTTPRequestLine::parse(), dodo::network::protocol::http::HTTPRequest::parse(), dodo::network::protocol::http::HTTPResponse::HTTPResponseLine::parse(), dodo::network::protocol::http::HTTPResponse::parse(), dodo::network::protocol::http::HTTPRequest::parseBody(), dodo::network::protocol::http::HTTPResponse::parseBody(), dodo::network::protocol::http::HTTPMessage::parseChunkedBody(), dodo::network::protocol::http::HTTPMessage::parseChunkHex(), dodo::network::protocol::http::HTTPMessage::parseCRLF(), dodo::network::protocol::http::HTTPMessage::parseFieldValue(), dodo::network::protocol::http::HTTPMessage::parseHeaders(), dodo::network::protocol::http::HTTPMessage::parseToken(), and dodo::network::protocol::http::HTTPMessage::parseUInt().
|
pure virtual |
If the buffer_ underflows, the buffer_ must be reset refilledwith new data from the source.
Implemented in dodo::network::StringReadBuffer, dodo::network::FileReadBuffer, and dodo::network::SocketReadBuffer.
|
protected |
The buffer.
Definition at line 81 of file socketreadbuffer.hpp.
Referenced by dodo::network::FileReadBuffer::FileReadBuffer(), dodo::network::SocketReadBuffer::get(), dodo::network::FileReadBuffer::get(), dodo::network::SocketReadBuffer::SocketReadBuffer(), dodo::network::SocketReadBuffer::underflow(), dodo::network::FileReadBuffer::underflow(), and dodo::network::SocketReadBuffer::~SocketReadBuffer().
|
protected |
The size of buffer_.
Definition at line 86 of file socketreadbuffer.hpp.
Referenced by dodo::network::FileReadBuffer::FileReadBuffer(), dodo::network::SocketReadBuffer::SocketReadBuffer(), dodo::network::SocketReadBuffer::underflow(), and dodo::network::FileReadBuffer::underflow().
|
protected |
The number underflow() invocations.
Definition at line 91 of file socketreadbuffer.hpp.
Referenced by getUnderflowCount(), dodo::network::SocketReadBuffer::underflow(), and dodo::network::FileReadBuffer::underflow().