streambuf
Streambuf buffer management is fairly sophisticated (this is a nice way to say "complicated"). The standard protocol has the following "areas":
The GNU streambuf
design extends this, but the details are
still evolving.
The following methods are used to manipulate these areas.
These are all protected methods, which are intended to be
used by virtual function in classes derived from streambuf
.
They are also all ANSI/ISO-standard, and the ugly names
are traditional.
(Note that if a pointer points to the 'end' of an area,
it means that it points to the character after the area.)
Method: char* streambuf::pbase () const
Returns a pointer to the start of the put area.
Method: char* streambuf::epptr () const
Returns a pointer to the end of the put area.
Method: char* streambuf::pptr () const
If pptr() < epptr ()
, the pptr()
returns a pointer to the current put position.
(In that case, the next write will
overwrite *pptr()
, and increment pptr()
.)
Otherwise, there is no put position available
(and the next character written will cause streambuf::overflow
to be called).
Method: void streambuf::pbump (int N)
Add N to the current put pointer. No error checking is done.
Method: void streambuf::setp (char* P, char* E)
Sets the start of the put area to P, the end of the put area to E, and the current put pointer to P (also).
Method: char* streambuf::eback () const
Returns a pointer to the start of the get area.
Method: char* streambuf::egptr () const
Returns a pointer to the end of the get area.
Method: char* streambuf::gptr () const
If gptr() < egptr ()
, then gptr()
returns a pointer to the current get position.
(In that case the next read will read *gptr()
,
and possibly increment gptr()
.)
Otherwise, there is no read position available
(and the next read will cause streambuf::underflow
to be called).
Method: void streambuf:gbump (int N)
Add N to the current get pointer. No error checking is done.
Method: void streambuf::setg (char* B, char* P, char* E)
Sets the start of the get area to B, the end of the get area to E, and the current put pointer to P.