Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JGZFileReader.hh
Go to the documentation of this file.
1#ifndef __JLANG__JGZFILEREADER__
2#define __JLANG__JGZFILEREADER__
3
4#include <istream>
5
6#include "JLang/gzstream.h"
9#include "JLang/JException.hh"
10
11
12/**
13 * \author mdejong
14 */
15
16namespace JLANG {}
17namespace JPP { using namespace JLANG; }
18
19namespace JLANG {
20
21
22 /**
23 * Object reading from gzipped file.
24 *
25 * This class implements the JAccessibleObjectIterator interface.
26 */
27 template<class T>
29 public igzstream,
30 public JStreamObjectIterator <T>,
32 {
33 public:
34 /**
35 * Default constructor.
36 */
38 igzstream(),
39 JStreamObjectIterator<T>(static_cast<std::istream&>(*this))
40 {}
41
42
43 /**
44 * Constructor.
45 *
46 * \param file_name file name
47 */
48 JGZFileReader(const char* file_name) :
50 igzstream(file_name),
51 JStreamObjectIterator<T>(static_cast<std::istream&>(*this))
52 {}
53
54
55 /**
56 * Check is file is open.
57 *
58 * \return true if open; else false
59 */
60 virtual bool is_open() const override
61 {
62 return igzstream::is_open();
63 }
64
65
66 /**
67 * Open file.
68 *
69 * \param file_name file name
70 */
71 virtual void open(const char* file_name) override
72 {
73 igzstream::open(file_name);
74
75 if (!this->is_open()) {
76 this->Throw(JFileOpenException(std::string("Error opening file ") + file_name));
77 }
78 }
79
80
81 /**
82 * Close file.
83 */
84 virtual void close() override
85 {
87 }
88 };
89}
90
91#endif
Exceptions.
Interface for object iteration with named access.
Interface for named access of a device.
Exception for opening of file.
Object reading from gzipped file.
JGZFileReader(const char *file_name)
Constructor.
virtual bool is_open() const override
Check is file is open.
JGZFileReader()
Default constructor.
virtual void close() override
Close file.
virtual void open(const char *file_name) override
Open file.
static void Throw(const bool option)
Definition JThrow.hh:37
bool is_open() const
Definition gzstream.h:194
void close()
Definition gzstream.h:185
void open(const char *name, int open_mode=std::ios::in)
Definition gzstream.h:208
Auxiliary classes and methods for language specific functionality.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).