Name

basic_filebuf class template — Class template for file buffers

Synopsis

template <class charT, class traits = char_traits<charT> >
class basic_filebuf : public basic_streambuf<charT,traits>
{
public:
  typedef charT char_type;
  typedef typename traits::int_type int_type;
  typedef typename traits::pos_type pos_type;
  typedef typename traits::off_type off_type;
  typedef traits traits_type;
   
  basic_filebuf(  );
  virtual ~basic_filebuf(  );
   
  bool is_open(  ) const;
  basic_filebuf<charT,traits>* 
    open(const char* filename, ios_base::openmode mode);
  basic_filebuf<charT,traits>* 
    open(const char* filename, ios_base::open_mode mode);
  basic_filebuf<charT,traits>* close(  );
protected:
  virtual streamsize showmanyc(  );
  virtual int_type underflow(  );
  virtual int_type uflow(  );
  virtual int_type pbackfail(int_type c = traits::eof(  ));
  virtual int_type overflow(int_type c = traits::eof(  ));
  virtual basic_streambuf<charT,traits>*
    setbuf(char_type* s, streamsize n);
  virtual pos_type seekoff(off_type off, ios_base::seekdir way,
    ios_base::openmode = ios_base::in | ios_base::out);
  virtual pos_type seekpos(pos_type newpos, 
    ios_base::openmode which = ios_base::in | ios_base::out);
  virtual int sync(  );
  virtual void imbue(const locale& loc);
};

The basic_filebuf class template implements a stream buffer that is associated with an external file. The connection to the external file is equivalent to calling C I/O functions (declared in <cstdio>) but may or may not actually call the C functions. For example, the open function ...

Get C++ In a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.