Very Simple Cross-Platform Library
|
#include <ReadingBuffer.h>
Public Member Functions | |
bool | read () |
Public Member Functions inherited from hu::varadiistvan::scpl::io::Buffer | |
Buffer (size_t capacity) | |
~Buffer () | |
size_t | getCapacity () const |
const unsigned char * | getData () const |
unsigned char * | getData () |
size_t | getLength () const |
bool | isEmpty () const |
size_t | getAvailable () const |
void | reset () |
size_t | addLength (size_t n) |
size_t | append (const void *src, size_t size) |
size_t | extract (void *dest, size_t size, size_t offset=0) const |
Public Member Functions inherited from hu::varadiistvan::scpl::io::FailableReference< ReadingBuffer > | |
bool | failed () const |
errorCode_t | getErrorCode () const |
void | repair () |
A buffer used for reading from a buffered stream. It cannot be created directly, only acquired from the stream.
It should be made empty, and then the function read() should be called on it. If it returns true, some data could be read. If the amount of data read is 0, that indicates and end-of-file condition.
Definition at line 49 of file ReadingBuffer.h.
bool hu::varadiistvan::scpl::io::ReadingBuffer::read | ( | ) |
Read into the buffer using the buffered stream if possible.
If the buffer contains data, this function returns immediately with success, so the buffer should be reset before reading.
If some data can be read immediately, that is stored in the buffer, and success is indicated. Success is indicated even if the amount of data read is 0, allowing for signalling the end-of-file or end-of-connection condition.
If the reading operation would block, the stream is set up so that it would read, and failure is returned.
Otherwise, if the reading operation fails for some other reason, the buffer's error code is set, so it should always be checked on a failure!