Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

basic_filebuf


basic_filebufbasic_streambuf

Summary

Class that associates the input or output sequence with a file.

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

Synopsis

#include <fstream> 
template<class charT, class traits = char_traits<charT> >
class basic_filebuf
: public basic_streambuf<charT, traits>

Description

The template class basic_filebuf is derived from basic_streambuf. It associates the input or output sequence with a file. Each object of type basic_filebuf<charT, traits> controls two character sequences:

The restrictions on reading and writing a sequence controlled by an object of class basic_filebuf<charT,traits> are the same as for reading and writing with the Standard C library files.

If the file is not open for reading, the input sequence cannot be read. If the file is not open for writing, the output sequence cannot be written. A joint file position is maintained for both the input and output sequences.

A file has byte sequences, so the basic_filebuf class treats a file as the external source (or sink) byte sequence. In order to provide the contents of a file as wide character sequences, a wide-oriented file buffer called wfilebuf converts wide character sequences to multibytes character sequences (and vice versa) according to the current locale being used in the stream buffer.

Interface

Types

char_type
filebuf
int_type
off_type
pos_type
traits_type
wfilebuf 

Constructors

basic_filebuf();
basic_filebuf(int fd);

Destructors

virtual ~basic_filebuf();

Member Functions

basic_filebuf<charT,traits>* 
close();
bool 
is_open() const; 
basic_filebuf<charT,traits>* 
open(const char* s, ios_base::openmode mode, 
   long protection = 0666); 
basic_filebuf<charT,traits>*
open(int fd);
int_type 
overflow(int_type c = traits::eof() ); 
int_type 
pbackfail(int_type c = traits::eof() ); 
pos_type 
seekoff(off_type off, ios_base::seekdir way,
        ios_base::openmode which = ios_base::in |
        ios_base::out); 
pos_type 
seekpos(pos_type sp,ios_base::openmode      which = ios_base::in | ios_base::out); 
basic_filebuf<charT,traits>* 
setbuf(char_type*s, streamsize n); 
int 
sync();
int_type 
underflow();
streamsize 
xsputn(const char_type* s, streamsize n); 

Example

See Also

char_traits(3C++),ios_base(3C++), basic_ios(3C++), basic_streambuf(3C++), basic_ifstream(3C++), basic_ofstream(3C++), basic_fstream(3C++)

Working Paper for Draft Proposed International Standard for Information Systems--Programming Language C++, Section 27.8.1.1

Standards Conformance

ANSI X3J16/ISO WG21 Joint C++ Committee



Previous fileTop of documentContentsIndexNext file
Copyright (c) 1998, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.
OEM Release, June 1998