|
LRAUV
revA
|
Utility for the concrete concern of reading lines from a given file descriptor in a non-blocking fashion. More...
#include <LineReader.h>
Public Member Functions | |
| LineReader (int fd, size_t bufferSize=1024, bool debug=false) | |
| Constructor. More... | |
| ~LineReader () | |
| int | readLine (char *buf, size_t bufSize) |
| Reads a line (or part of it depending on given output buffer size). More... | |
Protected Attributes | |
| int | fd_ |
Private Member Functions | |
| LineReader (const LineReader &old) | |
| void | adjustBuffer (size_t bufSize) |
| int | fillInBuffer () |
| void | updateBuffer (size_t processed) |
| int | nbRead (char *buffer, size_t bufferLength) |
Private Attributes | |
| char * | buffer_ |
| size_t | bufferSize_ |
| size_t | bufferRead_ |
| bool | debug_ |
Utility for the concrete concern of reading lines from a given file descriptor in a non-blocking fashion.
A line is any sequence of characters ending with '
'. Although somewhat similar with functionality offered by other classes, this separated module facilitates reuse in various scenarios. For example, to do line reads from stdin in combination with reads from sockets, etc. This class was added during the initial development of the socket-based interface with the ESP.
|
inline |
Constructor.
| fd | file descriptor to read data from |
| bufferSize | size for internal buffer; default: 1024 |
| debug | flag for ad hoc debug printing; default: false |
References buffer_, and bufferSize_.
|
inline |
References buffer_.
|
private |
|
private |
|
private |
|
private |
| int LineReader::readLine | ( | char * | buf, |
| size_t | bufSize | ||
| ) |
Reads a line (or part of it depending on given output buffer size).
The underlying read operation is non-blocking so multiple calls can be done until a complete line is received or until the size of data already received is equal or greater than the output buffer size.
| buf | output buffer |
| bufSize | size of output buffer |
Referenced by ESPComm::readLine().
|
private |
|
private |
Referenced by LineReader(), and ~LineReader().
|
private |
|
private |
Referenced by LineReader().
|
private |
|
protected |