21 #ifndef G_LINE_BUFFER_H
22 #define G_LINE_BUFFER_H
32 class LineBufferIterator ;
55 G_EXCEPTION( Error ,
"line buffer error" ) ;
61 explicit LineBuffer(
const std::string &
eol ,
bool do_throw_on_overflow =
false ) ;
66 void add(
const std::string & segment ) ;
69 void add(
const char * p , std::string::size_type n ) ;
72 const std::string &
eol()
const ;
86 bool check(
size_t )
const ;
93 bool m_throw_on_overflow ;
114 const std::string &
line()
const ;
118 std::string::const_iterator
begin()
const ;
122 std::string::const_iterator
end()
const ;
130 void expect(
size_t ) ;
135 std::string::size_type m_pos ;
136 std::string::size_type m_eol_size ;
137 std::string::const_iterator m_line_begin ;
138 std::string::const_iterator m_line_end ;
139 mutable std::string m_line ;
140 mutable bool m_line_valid ;
const std::string & eol() const
Returns the line-ending.
void add(const std::string &segment)
Adds a data segment.
void expect(size_t n)
The next 'n' bytes added and/or extracted are treated as a complete line.
std::string::const_iterator end() const
Returns an end iterator for the current line.
An iterator class for GNet::LineBuffer that extracts complete lines.
LineBuffer()
Default constructor for a line buffer that auto-detects either CR or CR-LF line endings based on the ...
LineBufferIterator(LineBuffer &)
Constructor.
~LineBufferIterator()
Destructor.
std::string::const_iterator begin() const
Returns a begin iterator for the current line.
const std::string & line() const
Returns the current line.
A class which does line buffering.
bool more()
Returns true if there is a line() to be had.