Template Class basic_ofstream
Defined in File gzio.hpp
Inheritance Relationships
Base Type
public cif::gzio::basic_ostream< CharT, Traits >
(Template Class basic_ostream)
Class Documentation
-
template<typename CharT, typename Traits>
class basic_ofstream : public cif::gzio::basic_ostream<CharT, Traits> Control output to files compressing the contents with gzip.
This is an ofstream implementation that can writeto named files compressing the content with gzip directly. The class inherits from std::basic_ostream 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_ofstream(const char *filename, std::ios_base::openmode mode = std::ios_base::out)
Construct an ofstream.
- Parameters
filename – Null terminated string specifying the file to open
mode – The mode in which to open the file
-
inline explicit basic_ofstream(const std::string &filename, std::ios_base::openmode mode = std::ios_base::out)
Construct an ofstream.
- Parameters
filename – std::string specifying the file to open
mode – The mode in which to open the file
-
inline explicit basic_ofstream(const std::filesystem::path &filename, std::ios_base::openmode mode = std::ios_base::out)
Construct an ofstream.
- Parameters
filename – std::filesystem::path specifying the file to open
mode – The mode in which to open the file
-
inline basic_ofstream(basic_ofstream &&rhs)
Move constructor.
-
inline basic_ofstream &operator=(basic_ofstream &&rhs)
Move operator=.
-
inline void open(const std::filesystem::path &filename, std::ios_base::openmode mode = std::ios_base::out)
Open the file filename with mode mode.
A compression algorithm is chosen upon the contents of the extension() of filename with .gz mapping to gzip compression and .xz to xz compression.
- 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::out)
Open the file filename with mode mode.
A compression algorithm is chosen upon the contents of the extension of filename with .gz mapping to gzip compression and .xz to xz compression.
- 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::out)
Open the file filename with mode mode.
A compression algorithm is chosen upon the contents of the extension of filename with .gz mapping to gzip compression and .xz to xz compression.
- 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_ofstream &rhs)
Swap the contents with those of rhs.
- Parameters
rhs – The ifstream to swap with