A class which does line buffering. More...
#include <glinebuffer.h>
Public Member Functions | |
LineBuffer (const std::string &eol=std::string("\n"), bool do_throw_on_overflow=false) | |
Constructor. More... | |
void | add (const std::string &segment) |
Adds a data segment. More... | |
void | add (const char *p, std::string::size_type n) |
Adds a data segment. More... | |
bool | more () const |
Returns true if there are complete line(s) to be extracted. More... | |
const std::string & | current () const |
Returns the current line, without extracting it. More... | |
void | discard () |
Discards the current line. More... | |
std::string | line () |
Extracts a line and returns it as a string. More... | |
Friends | |
class | LineBufferIterator |
A class which does line buffering.
Raw data is added, and newline-delimited lines are extracted.
Usage:
Definition at line 52 of file glinebuffer.h.
|
explicit |
void GNet::LineBuffer::add | ( | const std::string & | segment | ) |
Adds a data segment.
Definition at line 63 of file glinebuffer.cpp.
void GNet::LineBuffer::add | ( | const char * | p, |
std::string::size_type | n | ||
) |
const std::string & GNet::LineBuffer::current | ( | ) | const |
Returns the current line, without extracting it.
The line terminator is not included.
Precondition: more()
Definition at line 104 of file glinebuffer.cpp.
References G_ASSERT.
void GNet::LineBuffer::discard | ( | ) |
Discards the current line.
Precondition: more()
Definition at line 118 of file glinebuffer.cpp.
References G_ASSERT.
std::string GNet::LineBuffer::line | ( | ) |
Extracts a line and returns it as a string.
The line terminator is not included.
Definition at line 129 of file glinebuffer.cpp.
bool GNet::LineBuffer::more | ( | ) | const |
Returns true if there are complete line(s) to be extracted.
Definition at line 99 of file glinebuffer.cpp.
|
friend |
Definition at line 86 of file glinebuffer.h.