Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JGZFileWriter.hh
Go to the documentation of this file.
1#ifndef __JLANG__JGZFILEWRITER__
2#define __JLANG__JGZFILEWRITER__
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 ogzstream,
30 public JStreamObjectOutput <T>,
32 {
33 public:
34 /**
35 * Default constructor.
36 */
38 ogzstream(),
39 JStreamObjectOutput<T>(static_cast<std::ostream&>(*this), "")
40 {}
41
42
43 /**
44 * Constructor.
45 *
46 * \param file_name file name
47 */
48 JGZFileWriter(const char* file_name) :
50 ogzstream(file_name),
51 JStreamObjectOutput<T>(static_cast<std::ostream&>(*this), "")
52 {}
53
54
55 /**
56 * Constructor.
57 *
58 * \param file_name file name
59 * \param sep token separator
60 */
61 JGZFileWriter(const char* file_name,
62 const std::string& sep) :
64 ogzstream(file_name),
65 JStreamObjectOutput<T>(static_cast<std::ostream&>(*this), sep)
66 {}
67
68
69 /**
70 * Check is file is open.
71 *
72 * \return true if open; else false
73 */
74 virtual bool is_open() const override
75 {
76 return ogzstream::is_open();
77 }
78
79
80 /**
81 * Open file.
82 *
83 * \param file_name file name
84 */
85 virtual void open(const char* file_name) override
86 {
87 ogzstream::open(file_name);
88
89 if (!this->is_open()) {
90 this->Throw(JFileOpenException(std::string("Error opening file ") + file_name));
91 }
92 }
93
94
95 /**
96 * Close file.
97 */
98 virtual void close() override
99 {
101 }
102 };
103}
104
105#endif
Exceptions.
Interface for object output with named access.
Interface for named access of a device.
Exception for opening of file.
Object reading from gzipped file.
virtual bool is_open() const override
Check is file is open.
JGZFileWriter(const char *file_name, const std::string &sep)
Constructor.
virtual void open(const char *file_name) override
Open file.
virtual void close() override
Close file.
JGZFileWriter()
Default constructor.
JGZFileWriter(const char *file_name)
Constructor.
Template implementation of stream output for single data type.
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::out)
Definition gzstream.h:218
Auxiliary classes and methods for language specific functionality.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).