Template Class basic_ifstream

Inheritance Relationships

Base Type

Class Documentation

template<typename CharT, typename Traits>
class basic_ifstream : public cif::gzio::basic_istream<CharT, Traits>

Control input from files compressed with gzip.

This is an ifstream implementation that can read from named files compressed with gzip directly. The class inherits from std::basic_istream and offers all the associated functionality.

Template Parameters
  • CharT – Type of the character stream.

  • Traits – Traits for character type, defaults to char_traits<_CharT>.

Public Functions

inline explicit basic_ifstream(const char *filename, std::ios_base::openmode mode = std::ios_base::in)

Construct an ifstream.

Parameters
  • filename – Null terminated string specifying the file to open

  • mode – The mode in which to open the file

inline explicit basic_ifstream(const std::string &filename, std::ios_base::openmode mode = std::ios_base::in)

Construct an ifstream.

Parameters
  • filename – std::string specifying the file to open

  • mode – The mode in which to open the file

inline explicit basic_ifstream(const std::filesystem::path &filename, std::ios_base::openmode mode = std::ios_base::in)

Construct an ifstream.

Parameters
  • filename – std::filesystem::path specifying the file to open

  • mode – The mode in which to open the file

inline basic_ifstream(basic_ifstream &&rhs)

Move constructor.

inline basic_ifstream &operator=(basic_ifstream &&rhs)

Move version of operator=.

inline void open(const std::filesystem::path &filename, std::ios_base::openmode mode = std::ios_base::in)

Open the file filename with mode mode.

Parameters
  • filename – std::filesystem::path specifying the file to open

  • mode – The mode in which to open the file

inline void open(const std::string &filename, std::ios_base::openmode mode = std::ios_base::in)

Open the file filename with mode mode.

Parameters
  • filename – std::string specifying the file to open

  • mode – The mode in which to open the file

inline void open(const char *filename, std::ios_base::openmode mode = std::ios_base::in)

Open the file filename with mode mode.

Parameters
  • filename – Null terminated string specifying the file to open

  • mode – The mode in which to open the file

inline bool is_open() const

Return true if the file is open.

Returns

m_filebuf.is_open()

inline void close()

Close the file.

Calls m_filebuf.close(). If that fails, the failbit is set.

inline void swap(basic_ifstream &rhs)

Swap the contents with those of rhs.

Parameters

rhs – The ifstream to swap with