Boost C++ Libraries

PrevUpHomeNext

Class template basic_filebuf

boost::filesystem::basic_filebuf — File buffer class template.

Synopsis

// In header: <boost/filesystem/fstream.hpp>

template<typename Char, typename Traits = std::char_traits< Char > > 
class basic_filebuf :
  public std::basic_filebuf< Char, std::char_traits< Char > >
{
public:

  // public member functions
  basic_filebuf() = default;
  basic_filebuf(basic_filebuf &&) = default;
  basic_filebuf & operator=(basic_filebuf &&) = default;
  basic_filebuf(basic_filebuf const &) = delete;
  basic_filebuf const & operator=(basic_filebuf const &) = delete;
  basic_filebuf * open(path const &, std::ios_base::openmode);
};

Description

The class template is equivalent to std::basic_filebuf from <fstream> with the only difference being that the open method accepts path as the first argument.

basic_filebuf public member functions

  1. basic_filebuf() = default;
  2. basic_filebuf(basic_filebuf &&) = default;
  3. basic_filebuf & operator=(basic_filebuf &&) = default;
  4. basic_filebuf(basic_filebuf const &) = delete;
  5. basic_filebuf const & operator=(basic_filebuf const &) = delete;
  6. basic_filebuf * open(path const & p, std::ios_base::openmode mode);
    Opens a file identified by p.

    This method is equivalent to std::basic_filebuf::open, except that it accepts path as the first argument. The implementation will attempt to open the file using the native path character encoding, if possible. If std::basic_filebuf implementation does not support opening files using the native path character encoding, the implementation will perform path character code conversion by calling path methods, using the locale facet returned by path::codecvt.

    Error Reporting: 

    C++ standard library and system errors are reported as documented by std::basic_filebuf::open. Additionally, an exception may be thrown by one of the path methods as part of character code conversion, if called by the implementation.

    Parameters:

    p

    Path to the file.

    mode

    File opening mode. Refer to std::basic_filebuf::open documentation for the supported modes.

    Returns:

    this if the file was successfully opened, otherwise a null pointer.


PrevUpHomeNext