basic_streambuf
streambuf
wstreambuf
Buffer class for streams
iostream library
  cplusplus.com  

Standard hierarchy

streambuf
--->
filebuf
--->
stringbuf

Public member functions:

pubimbueImbue locale
getlocGet current locale
pubsetbufSet buffer array
pubseekoffSet relative position of internal position pointer
pubseekposSet absolute position of internal position pointer
pubsyncSynchronize stream
in_availGet number of characters available in input buffer
snextcIncrease get pointer and return next character
sbumpcGet current character and increase get pointer
sgetcGet current character
sgetnGet some characters
sputbackcPut character back
sungetcDecrease get pointer
sputcStore character at current put position and increase put pointer
sputnWrite some characters
(destructor)No-op [virtual]

Protected member functions:

(constructor)Construct an object
ebackGet pointer to beginning of input sequence
egptrGet pointer to end of input seuqence
epptrGet pointer to end of output sequence
gbumpIncrease get pointer
gptrReturn get pointer
pbaseGet pointer to beginning of output sequence
pbumpIncrease put pointer
pptrReturn put pointer
setgSet input buffer pointers
setpSet output buffer pointers
imbueImbue locale [virtual]
overflowPut character at current position [virtual]
pbackfailPut character back [virtual]
seekoffSet relative position of internal position pointer [virtual]
seekposSet absolute position of internal position pointer [virtual]
setbufSet buffer [virtual]
showmanycGet number of characters availbale in input sequence [virtual]
syncSynchronize stream buffer [virtual]
uflowGet current character [virtual]
underflowGet current character [virtual]
xsgetnGet some characters [virtual]
xsputnWrite some characters [virtual]

Description:

  This is an abstract base class for deriving stream buffer objects.
  A streambuf-derived object mantains internally a locale object and up to two character sequences: one used as input sequence, where characters are extracted from, and the other is the output sequence, where output characters are written. An object may have access to one, both, or none of these sequences depending on the type of strembuf-derived object and the openmode used.
  Both, input and output sequence, are related in a way that one may be affected by changes on the other, for example, a character written may be later read in a stream buffer that supports both input and output operations.
  Each stream object of the iostream hierarchy mantains internally a pointer to a streambuf or a strembuf-derived object.
  The streambuf class is an elaborated abstract base class with three main groups of members:
Public members
These provide the interface to interact with the class with members common to all streambuf-derived objects. They are strongly dependent on the protected members. Depending on wether they affect the input sequence, the ouput sequence, both or the locale they fall into these categories:
Protected members (non-virtual)
These provide an internal interface that is used by other members to access the internal pointers. Each streambuf-derived class can access the three internal pointers that determine the boundaries and the current position of the input sequence and the three internal pointers that determine the output sequence. These pointers and the functions to access their values for the input and output sequence are:
Internal pointerinput sequenceoutput sequence
Beginning of sequenceebackpbase
Next element in the sequencegptrpptr
End (just past last element) of sequenceegptrepptr
  The values of all these internal pointers may be modified by calling members setg for the ones of the input sequence and setp for the pointers of the output sequence.
  gptr and pptr are known as get pointer and put pointer and may be increased by calling gbump and pbump respectivelly.
Virtual protected members
These members are designed to be overriden by derived classes. Most of them expect a very specific behavior in the derived class because they are called by other non-virtual members.
These members have a very important function in the derived classes; They are in charge of performing the physical input and ouput operations and translations between a physical or logical device (like a file) and the internal sequences of characters (simple arrays in memory).
 


© The C++ Resources Network, 2001