cplusplus.com cplusplus.com
cplusplus.com   C++ : Reference : IOstream Library : filebuf
- -
C++
Information
Documentation
Reference
Articles
Sourcecode
Forum
Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
IOstream Library
manipulators
classes:
· filebuf
· fstream
· ifstream
· ios
· iostream
· ios_base
· istream
· istringstream
· ofstream
· ostream
· ostringstream
· streambuf
· stringbuf
· stringstream
objects:
· cerr
· cin
· clog
· cout
types:
· fpos
· streamoff
· streampos
· streamsize
filebuf
· filebuf::filebuf
· filebuf::~filebuf
member functions:
· filebuf::close
· filebuf::is_open
· filebuf::open
virtual members:
· filebuf::imbue
· filebuf::overflow
· filebuf::pbackfail
· filebuf::seekoff
· filebuf::seekpos
· filebuf::setbuf
· filebuf::showmanyc
· filebuf::sync
· filebuf::uflow
· filebuf::underflow

-

filebuf class
<fstream>

File stream buffer

Class hierarchy:

filebuf

This class applies the functionality of the streambuf class to read and write from/to files.

By calling member open, a physical file is associated to the file buffer as its associated character sequence. Depending on the mode used in this operation, the access to the controlled input sequence or the controlled output sequence may be restricted.

The state of the filebuf object -i.e. wether a file is open or not- may be tested by calling member function is_open.

Internally, filebuf objects operate as defined in the streambuf class (see streambuf), with the particularity that a joint position pointer is maintained for both the input and the output controlled sequences.

The class overrides some virtual members inherited from streambuf to provide a specific functionality for files.

Public members

(constructor) Construct a file stream buffer object (constructor member)
(destructor) Destruct object (destructor member)
is_open Check if a file is open (public member function)
open Open file (public member function)
close Close file (public member function)

Public members inherited from streambuf:

getloc Get current locale (public member function)
in_avail Get number of characters available to read (public member function)
pubimbue Imbue locale (public member function)
pubseekoff Set internal position pointer to relative position (public member function)
pubseekpos Set internal position pointer to absolute position (public member function)
pubsetbuf Set buffer array (public member function)
pubsync Synchronize stream buffer (public member function)
sbumpc Get current character and increase get pointer (public member function)
sgetc Get current character (public member function)
sgetn Get sequence of characters (public member function)
snextc Increase get pointer and return next character (public member function)
sputbackc Put character back (public member function)
sputc Store character at current put position and increase put pointer (public member function)
sputn Write a sequence of characters (public member function)

Virtual protected members

The parent class streambuf defines several protected virtual functions that are called by the other member functions to perform the operations on the associated character sequence. Derived classes override these virtual member functions as necessary to provide the functionality for their specific types of buffer. filebuf overrides the following:

showmanyc Get number of characters available in the sequence (virtual protected member function)
underflow Get character in the case of underflow (virtual protected member function)
uflow Get character in the case of underflow and advance get pointer (virtual protected member function)
pbackfail Put character back on backup underflow (virtual protected member)
overflow Write character (virtual protected member function)
setbuf Set buffer (virtual protected member function)
seekoff Set internal position pointer to relative position (virtual protected member function)
seekpos Set internal position pointer to absolute position (virtual protected member function)
sync Synchronize file buffer (virtual protected member function)
imbue Imbue locale (virtual protected member function)

The remaining virtual protectected members (xsgetn and xsputn) are left with their by-default behavior defined in streambuf.

Protected members

The class also inherits several non-virtual protected members used by the public functions to access the internal pointers. See streambuf for more info.

© The C++ Resources Network, 2000-2007 - All rights reserved
Spotted an error? - contact us