|
dodo
0.0.1
A C++ library to create containerized Linux services
|
File-based VirtualReadBuffer, conventient for testing purposes as parsers can be tested against file instead of network sources. More...
#include <socketreadbuffer.hpp>


Public Member Functions | |
| FileReadBuffer (std::string filename, size_t bufsize=8192) | |
| Construct a FileReadBuffer. More... | |
| virtual char | get () const |
| Get the current char from VirtualReadBuffer. More... | |
| virtual common::SystemError | next () |
| Move to the next char from the VirtualReadBuffer. More... | |
| virtual common::SystemError | underflow () |
| If the buffer_ underflows, the buffer_ must be reset refilledwith new data from the source. More... | |
Public Member Functions inherited from dodo::network::VirtualReadBuffer | |
| size_t | getUnderflowCount () const |
| Return the number of times underflow() was invoked. More... | |
Protected Attributes | |
| FILE * | file_ |
| The file handle. More... | |
| size_t | idx_ |
| The index into the buffer. More... | |
| size_t | read_ |
| The number of chars read in buffer_. More... | |
Protected Attributes inherited from dodo::network::VirtualReadBuffer | |
| char * | buffer_ |
| The buffer. More... | |
| ssize_t | bufsize_ |
| The size of buffer_. More... | |
| size_t | underflows_ |
| The number underflow() invocations. More... | |
File-based VirtualReadBuffer, conventient for testing purposes as parsers can be tested against file instead of network sources.
Definition at line 148 of file socketreadbuffer.hpp.
|
explicit |
Construct a FileReadBuffer.
| filename | The file to read. |
| bufsize | The buffer size to use |
Definition at line 63 of file socketreadbuffer.cpp.
References dodo::network::VirtualReadBuffer::buffer_, dodo::network::VirtualReadBuffer::bufsize_, dodo::common::SystemError::ecOK, file_, idx_, read_, throw_SystemException, and underflow().

|
virtual |
Get the current char from VirtualReadBuffer.
Implements dodo::network::VirtualReadBuffer.
Definition at line 91 of file socketreadbuffer.cpp.
References dodo::network::VirtualReadBuffer::buffer_, and idx_.
|
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).
Implements dodo::network::VirtualReadBuffer.
Definition at line 95 of file socketreadbuffer.cpp.
References idx_, and underflow().

|
virtual |
If the buffer_ underflows, the buffer_ must be reset refilledwith new data from the source.
Implements dodo::network::VirtualReadBuffer.
Definition at line 79 of file socketreadbuffer.cpp.
References dodo::network::VirtualReadBuffer::buffer_, dodo::network::VirtualReadBuffer::bufsize_, dodo::common::SystemError::ecEAGAIN, dodo::common::SystemError::ecOK, file_, idx_, read_, and dodo::network::VirtualReadBuffer::underflows_.
Referenced by FileReadBuffer(), and next().

|
protected |
The file handle.
Definition at line 169 of file socketreadbuffer.hpp.
Referenced by FileReadBuffer(), and underflow().
|
protected |
The index into the buffer.
Definition at line 172 of file socketreadbuffer.hpp.
Referenced by FileReadBuffer(), get(), next(), and underflow().
|
protected |
The number of chars read in buffer_.
Definition at line 177 of file socketreadbuffer.hpp.
Referenced by FileReadBuffer(), and underflow().