Boost C++ Libraries

PrevUpHomeNext

Class template basic_fstream

boost::filesystem::basic_fstream — Input/output file stream class template.

Synopsis

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

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

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

Description

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

basic_fstream public member functions

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

    This method is equivalent to the std::basic_fstream 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_fstream 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_fstream 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_fstream constructor documentation for the supported modes.

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

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


PrevUpHomeNext