Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JLANG::JGZFileWriter< T > Class Template Reference

Object reading from gzipped file. More...

#include <JGZFileWriter.hh>

Inheritance diagram for JLANG::JGZFileWriter< T >:
ogzstream JLANG::JStreamObjectOutput< T > JLANG::JAccessibleObjectOutput< T > gzstreambase JLANG::JObjectOutput< T > JLANG::JObjectOutput< T > JLANG::JAccessible JLANG::JThrow< JAccessible >

Public Member Functions

 JGZFileWriter ()
 Default constructor.
 
 JGZFileWriter (const char *file_name)
 Constructor.
 
 JGZFileWriter (const char *file_name, const std::string &sep)
 Constructor.
 
virtual bool is_open () const override
 Check is file is open.
 
virtual void open (const char *file_name) override
 Open file.
 
virtual void close () override
 Close file.
 
void open (const char *name, int open_mode=std::ios::out)
 
gzstreambufrdbuf ()
 
virtual bool put (const T &object) override
 Object output.
 
const std::string & getSeparator () const
 Get token separator.
 
void setSeparator (const std::string &sep)
 Set token separator.
 

Static Public Member Functions

static void Throw (const bool option)
 Enable/disable throw option.
 
static int Throw (const JException_t &error, const int value=-1)
 Throw exception or return error.
 

Protected Attributes

gzstreambuf buf
 

Static Protected Attributes

static bool do_throw
 throw option
 

Private Attributes

std::ostream & __out
 
std::string __sep
 

Detailed Description

template<class T>
class JLANG::JGZFileWriter< T >

Object reading from gzipped file.

This class implements the JAccessibleObjectIterator interface.

Definition at line 28 of file JGZFileWriter.hh.

Constructor & Destructor Documentation

◆ JGZFileWriter() [1/3]

template<class T >
JLANG::JGZFileWriter< T >::JGZFileWriter ( )
inline

Default constructor.

Definition at line 37 of file JGZFileWriter.hh.

37 :
38 ogzstream(),
39 JStreamObjectOutput<T>(static_cast<std::ostream&>(*this), "")
40 {}
JStreamObjectOutput(std::ostream &out, const std::string &sep="")
Constructor.

◆ JGZFileWriter() [2/3]

template<class T >
JLANG::JGZFileWriter< T >::JGZFileWriter ( const char * file_name)
inline

Constructor.

Parameters
file_namefile name

Definition at line 48 of file JGZFileWriter.hh.

48 :
50 ogzstream(file_name),
51 JStreamObjectOutput<T>(static_cast<std::ostream&>(*this), "")
52 {}
JAccessible()
Default constructor.

◆ JGZFileWriter() [3/3]

template<class T >
JLANG::JGZFileWriter< T >::JGZFileWriter ( const char * file_name,
const std::string & sep )
inline

Constructor.

Parameters
file_namefile name
septoken separator

Definition at line 61 of file JGZFileWriter.hh.

62 :
64 ogzstream(file_name),
65 JStreamObjectOutput<T>(static_cast<std::ostream&>(*this), sep)
66 {}

Member Function Documentation

◆ is_open()

template<class T >
virtual bool JLANG::JGZFileWriter< T >::is_open ( ) const
inlineoverridevirtual

Check is file is open.

Returns
true if open; else false

Implements JLANG::JAccessible.

Definition at line 74 of file JGZFileWriter.hh.

75 {
76 return ogzstream::is_open();
77 }
bool is_open() const
Definition gzstream.h:194

◆ open() [1/2]

template<class T >
virtual void JLANG::JGZFileWriter< T >::open ( const char * file_name)
inlineoverridevirtual

Open file.

Parameters
file_namefile name

Implements JLANG::JAccessible.

Definition at line 85 of file JGZFileWriter.hh.

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 }
virtual bool is_open() const override
Check is file is open.
static void Throw(const bool option)
Definition JThrow.hh:37
void open(const char *name, int open_mode=std::ios::out)
Definition gzstream.h:218

◆ close()

template<class T >
virtual void JLANG::JGZFileWriter< T >::close ( )
inlineoverridevirtual

Close file.

Implements JLANG::JAccessible.

Definition at line 98 of file JGZFileWriter.hh.

99 {
101 }
void close()
Definition gzstream.h:185

◆ open() [2/2]

void ogzstream::open ( const char * name,
int open_mode = std::ios::out )
inlineinherited

Definition at line 218 of file gzstream.h.

218 {
219 gzstreambase::open( name, open_mode);
220 }
void open(const char *name, int open_mode)
Definition gzstream.h:180

◆ rdbuf()

gzstreambuf * gzstreambase::rdbuf ( )
inlineinherited

Definition at line 193 of file gzstream.h.

193{ return &buf; }
gzstreambuf buf
Definition gzstream.h:169

◆ put()

template<class T >
virtual bool JLANG::JStreamObjectOutput< T >::put ( const T & object)
inlineoverridevirtualinherited

Object output.

Parameters
objectobject
Returns
true if OK; else false

Implements JLANG::JObjectOutput< T >.

Definition at line 51 of file JStreamObjectOutput.hh.

52 {
53 __out << object << __sep;
54
55 return (bool) __out;
56 }

◆ getSeparator()

template<class T >
const std::string & JLANG::JStreamObjectOutput< T >::getSeparator ( ) const
inlineinherited

Get token separator.

Returns
separator

Definition at line 64 of file JStreamObjectOutput.hh.

65 {
66 return this->__sep;
67 }

◆ setSeparator()

template<class T >
void JLANG::JStreamObjectOutput< T >::setSeparator ( const std::string & sep)
inlineinherited

Set token separator.

Parameters
sepseparator

Definition at line 75 of file JStreamObjectOutput.hh.

76 {
77 this->__sep = sep;
78 }

◆ Throw() [1/2]

static void JLANG::JThrow< JAccessible >::Throw ( const bool option)
inlinestaticinherited

Enable/disable throw option.

Parameters
optiontrue enable; false disable

Definition at line 37 of file JThrow.hh.

38 {
39 do_throw = option;
40 }

◆ Throw() [2/2]

static int JLANG::JThrow< JAccessible >::Throw ( const JException_t & error,
const int value = -1 )
inlinestaticinherited

Throw exception or return error.

Parameters
errorexception
valuereturn code
Returns
return code

Definition at line 51 of file JThrow.hh.

52 {
53 using namespace std;
54
55 if (do_throw) {
56 throw error;
57 }
58
59 cerr << error.what() << endl;
60
61 return value;
62 }

Member Data Documentation

◆ buf

gzstreambuf gzstreambase::buf
protectedinherited

Definition at line 169 of file gzstream.h.

◆ __out

template<class T >
std::ostream& JLANG::JStreamObjectOutput< T >::__out
privateinherited

Definition at line 81 of file JStreamObjectOutput.hh.

◆ __sep

template<class T >
std::string JLANG::JStreamObjectOutput< T >::__sep
privateinherited

Definition at line 82 of file JStreamObjectOutput.hh.

◆ do_throw

bool JLANG::JThrow< JAccessible >::do_throw
staticprotectedinherited

throw option

Set default throw option to true.

Definition at line 28 of file JThrow.hh.


The documentation for this class was generated from the following file: