Boost C++ Libraries

PrevUpHomeNext

Class template basic_ofstream

boost::filesystem::basic_ofstream — Output file stream class template.

Synopsis

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

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

  // public member functions
  basic_ofstream() = default;
  explicit basic_ofstream(path const &, 
                          std::ios_base::openmode = std::ios_base::out);
  basic_ofstream(basic_ofstream &&);
  basic_ofstream & operator=(basic_ofstream &&);
  basic_ofstream(basic_ofstream const &) = delete;
  basic_ofstream const & operator=(basic_ofstream const &) = delete;
  void open(path const &, std::ios_base::openmode = std::ios_base::out);
};

Description

The class template is equivalent to std::basic_ofstream from <fstream> with the only difference being that the constructors and open methods accept path as the first argument.

basic_ofstream public member functions

  1. basic_ofstream() = default;
  2. explicit basic_ofstream(path const & p, 
                            std::ios_base::openmode mode = std::ios_base::out);
    Constructs a stream and opens a file identified by p.

    This method is equivalent to the std::basic_ofstream constructor taking a path string and mode as arguments, 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_ofstream 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 the std::basic_ofstream constructor. 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 the std::basic_ofstream constructor documentation for the supported modes.

  3. basic_ofstream(basic_ofstream && that);
  4. basic_ofstream & operator=(basic_ofstream && that);
  5. basic_ofstream(basic_ofstream const &) = delete;
  6. basic_ofstream const & operator=(basic_ofstream const &) = delete;
  7. void open(path const & p, std::ios_base::openmode mode = std::ios_base::out);
    Opens a file identified by p.

    This method is equivalent to std::basic_ofstream::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_ofstream 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_ofstream::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_ofstream::open documentation for the supported modes.


PrevUpHomeNext