From dd25480c2ded406ad22a97576b3e26ad7ecfa9f3 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 21 Aug 2022 11:23:04 +0200 Subject: [PATCH] Base: implement default constructor and open() function for Base::ifstream and Base::ofstream --- src/Base/Stream.h | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/Base/Stream.h b/src/Base/Stream.h index 190cd8d2d7..e4b1ec3893 100644 --- a/src/Base/Stream.h +++ b/src/Base/Stream.h @@ -339,16 +339,23 @@ class FileInfo; class ofstream : public std::ofstream { public: + ofstream() = default; ofstream(const FileInfo& fi, ios_base::openmode mode = std::ios::out | std::ios::trunc) #ifdef _MSC_VER - : std::ofstream(fi.toStdWString().c_str(), mode) + : std::ofstream(fi.toStdWString().c_str(), mode) {} #else - : std::ofstream(fi.filePath().c_str(), mode) + : std::ofstream(fi.filePath().c_str(), mode) {} #endif - { - } ~ofstream() override = default; + void open(const FileInfo& fi, ios_base::openmode mode = + std::ios::out | std::ios::trunc) { +#ifdef _MSC_VER + std::ofstream::open(fi.toStdWString().c_str(), mode); +#else + std::ofstream::open(fi.filePath().c_str(), mode); +#endif + } }; /** @@ -360,16 +367,23 @@ public: class ifstream : public std::ifstream { public: + ifstream() = default; ifstream(const FileInfo& fi, ios_base::openmode mode = std::ios::in) #ifdef _MSC_VER - : std::ifstream(fi.toStdWString().c_str(), mode) + : std::ifstream(fi.toStdWString().c_str(), mode) {} #else - : std::ifstream(fi.filePath().c_str(), mode) + : std::ifstream(fi.filePath().c_str(), mode) {} #endif - { - } ~ifstream() override = default; + void open(const FileInfo& fi, ios_base::openmode mode = + std::ios::in) { +#ifdef _MSC_VER + std::ifstream::open(fi.toStdWString().c_str(), mode); +#else + std::ifstream::open(fi.filePath().c_str(), mode); +#endif + } }; } // namespace Base