proxygen
|
#include <LineReader.h>
Public Types | |
enum | State { kReading, kEof, kError } |
Public Member Functions | |
LineReader (int fd, char *buf, size_t bufSize) | |
State | readLine (StringPiece &line) |
Private Attributes | |
int const | fd_ |
char *const | buf_ |
char *const | bufEnd_ |
char * | bol_ |
char * | eol_ |
char * | end_ |
State | state_ |
Async-signal-safe line reader.
Definition at line 31 of file LineReader.h.
folly::symbolizer::LineReader::LineReader | ( | int | fd, |
char * | buf, | ||
size_t | bufSize | ||
) |
Create a line reader that reads into a user-provided buffer (of size bufSize).
Definition at line 26 of file LineReader.cpp.
LineReader::State folly::symbolizer::LineReader::readLine | ( | StringPiece & | line | ) |
Read the next line from the file.
If the line is at most bufSize characters long, including the trailing newline, it will be returned (including the trailing newline).
If the line is longer than bufSize, we return the first bufSize bytes (which won't include a trailing newline) and then continue from that point onwards.
The lines returned are not null-terminated.
Returns kReading with a valid line, kEof if at end of file, or kError if a read error was encountered.
Example: bufSize = 10 input has "hello world\n" The first call returns "hello worl" The second call returns "d\n"
Definition at line 35 of file LineReader.cpp.
References folly::Range< Iter >::assign(), bol_, buf_, bufEnd_, end_, eol_, fd_, kEof, kError, kReading, folly::readFull(), and state_.
Referenced by folly::symbolizer::test::expect().
|
private |
Definition at line 82 of file LineReader.h.
Referenced by readLine().
|
private |
Definition at line 69 of file LineReader.h.
Referenced by readLine().
|
private |
Definition at line 70 of file LineReader.h.
Referenced by readLine().
|
private |
Definition at line 84 of file LineReader.h.
Referenced by readLine().
|
private |
Definition at line 83 of file LineReader.h.
Referenced by readLine().
|
private |
Definition at line 68 of file LineReader.h.
Referenced by readLine().
|
private |
Definition at line 85 of file LineReader.h.
Referenced by readLine().