#ifndef __JLANG__JGZFILEREADER__ #define __JLANG__JGZFILEREADER__ #include #include "JLang/gzstream.h" #include "JLang/JAccessible.hh" #include "JLang/JStreamObjectIterator.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 JGZFileReader : public igzstream, public JStreamObjectIterator , public JAccessibleObjectIterator { public: /** * Default constructor. */ JGZFileReader() : igzstream(), JStreamObjectIterator(static_cast(*this)) {} /** * Constructor. * * \param file_name file name */ JGZFileReader(const char* file_name) : JAccessible(), igzstream(file_name), JStreamObjectIterator(static_cast(*this)) {} /** * Check is file is open. * * \return true if open; else false */ virtual bool is_open() const override { return igzstream::is_open(); } /** * Open file. * * \param file_name file name */ virtual void open(const char* file_name) override { igzstream::open(file_name); if (!this->is_open()) { this->Throw(JFileOpenException(std::string("Error opening file ") + file_name)); } } /** * Close file. */ virtual void close() override { igzstream::close(); } }; } #endif