Boost C++ Libraries

PrevUpHomeNext

Class template basic_ifstream

boost::filesystem::basic_ifstream — Input file stream class template.

Synopsis

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

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

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

Description

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

basic_ifstream public member functions

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

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

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

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


PrevUpHomeNext