◄Up► ◄Contents► ◄Index► ◄Back► ──The Microsoft iostream Classes──────────────────────────────────────────── Description All the iostream classes in the ios hierarchy depend on an attached streambuf class for the actual I/O processing. This class is an abstract class, but the iostream class library contains the following derived buffer classes for use with streams: ◄filebuf► Buffered disk file I/O. ◄strstreambuf► Stream data held entirely within an in-memory byte array. ◄stdiobuf► Disk I/O with buffering done by the underlying standard I/O system. All streambuf objects, when configured for buffered processing, maintain a fixed memory buffer, called a reserve area, that can be dynamically partitioned into a get area for input and a put area for output. These areas may or may not overlap. Protected member functions allow access and manipulation of a get pointer for character retrieval and a put pointer for character storage. The exact behavior of the buffers and pointers depends on the implementation of the derived class. The capabilities of the iostream classes can be extended significantly through the derivation of new streambuf classes. The ios class tree supplies the programming interface and all formatting features, but the streambuf class does the real work. The ios classes call the streambuf public members, including a set of virtual functions. The streambuf class provides a default implementation of certain virtual member functions. The "Default Implementation" section for each such function suggests function behavior for the derived class. #include <iostream.h> Public Members Character Input Functions ◄in_avail► Returns the number of characters in the get area. ◄sgetc► Returns the character at the get pointer, but does not move the pointer. ◄snextc► Advances the get pointer, then returns the next character. ◄sbumpc► Returns the current character, and then advances the get pointer. ◄stossc► Moves the get pointer forward one position, but does not return a character. ◄sputbackc► Attempts to move the get pointer back one position. ◄sgetn► Gets a sequence of characters from the streambuf object's buffer. Character Output Functions ◄out_waiting► Returns the number of characters in the put area. ◄sputc► Stores a character in the put area and advances the put pointer. ◄sputn► Stores a sequence of characters in the streambuf object's buffer and advances the put pointer. Diagnostic Functions ◄dbp► Prints buffer statistics and pointer values. Virtual Functions ◄sync► Empties the get area and the put area. ◄setbuf► Attempts to attach a reserve area to the streambuf object. ◄seekoff► Seeks to a specified offset. ◄seekpos► Seeks to a specified position. ◄overflow► Empties the put area. ◄underflow► Fills the get area if necessary. ◄pbackfail► Augments the sputbackc function. Protected Members Construction/Destruction ◄streambuf► Constructors for use in derived classes. ◄~streambuf► Virtual destructor. Other Protected Member Functions ◄base► Returns a pointer to the start of the reserve area. ◄ebuf► Returns a pointer to the end of the reserve area. ◄blen► Returns the size of the reserve area. ◄pbase► Returns a pointer to the start of the put area. ◄pptr► Returns the put pointer. ◄epptr► Returns a pointer to the end of the put area. ◄eback► Returns the lower bound of the get area. ◄gptr► Returns the get pointer. ◄egptr► Returns a pointer to the end of the get area. ◄setp► Sets all the put area pointers. ◄setg► Sets all the get area pointers. ◄pbump► Increments the put pointer. ◄gbump► Increments the get pointer. ◄setb► Sets up the reserve area. ◄unbuffered► Tests or sets the streambuf buffer state variable. ◄allocate► Allocates a buffer, if needed, by calling doalloc. ◄doallocate► Allocates a reserve area (virtual function). -♦-