#ifndef __JLANG__JGZFILEWRITER__ #define __JLANG__JGZFILEWRITER__ #include #include "JLang/gzstream.h" #include "JLang/JAccessible.hh" #include "JLang/JStreamObjectOutput.hh" #include "JLang/JException.hh" /** * \author mdejong */ namespace JLANG {} namespace JPP { using namespace JLANG; } namespace JLANG { /** * Object reading from gzipped file. * * This class implements the JAccessibleObjectIterator interface. */ template class JGZFileWriter : public ogzstream, public JStreamObjectOutput , public JAccessibleObjectOutput { public: /** * Default constructor. */ JGZFileWriter() : ogzstream(), JStreamObjectOutput(static_cast(*this), "") {} /** * Constructor. * * \param file_name file name */ JGZFileWriter(const char* file_name) : JAccessible(), ogzstream(file_name), JStreamObjectOutput(static_cast(*this), "") {} /** * Constructor. * * \param file_name file name * \param sep token separator */ JGZFileWriter(const char* file_name, const std::string& sep) : JAccessible(), ogzstream(file_name), JStreamObjectOutput(static_cast(*this), sep) {} /** * Check is file is open. * * \return true if open; else false */ virtual bool is_open() const override { return ogzstream::is_open(); } /** * Open file. * * \param file_name file name */ virtual void open(const char* file_name) override { ogzstream::open(file_name); if (!this->is_open()) { this->Throw(JFileOpenException(std::string("Error opening file ") + file_name)); } } /** * Close file. */ virtual void close() override { ogzstream::close(); } }; } #endif