Jpp  16.0.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Static Protected Attributes | List of all members
JLANG::JGZFileReader< T > Class Template Reference

Object reading from gzipped file. More...

#include <JGZFileReader.hh>

Inheritance diagram for JLANG::JGZFileReader< T >:
igzstream JLANG::JStreamObjectIterator< T > JLANG::JAccessibleObjectIterator< T > gzstreambase JLANG::JAbstractObjectIterator< T > JLANG::JObjectIterator< T > JLANG::JAccessible JLANG::JObjectIterator< T > JLANG::JThrow< JAccessible >

Public Types

typedef JObjectIterator< T >
::pointer_type 
pointer_type
 

Public Member Functions

 JGZFileReader ()
 Default constructor. More...
 
 JGZFileReader (const char *file_name)
 Constructor. More...
 
virtual bool is_open () const override
 Check is file is open. More...
 
virtual void open (const char *file_name) override
 Open file. More...
 
virtual void close () override
 Close file. More...
 
void open (const char *name, int open_mode=std::ios::in)
 
gzstreambufrdbuf ()
 
virtual bool setObject (T &object) override
 Set object. More...
 
virtual bool hasNext () override
 Check availability of next element. More...
 
virtual const pointer_typenext () override
 Get next element. More...
 
virtual skip_type skip (const skip_type ns)
 Skip items. More...
 

Static Public Member Functions

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

Protected Attributes

gzstreambuf buf
 
std::istream & __in
 
T object
 object More...
 
bool has_next
 status More...
 

Static Protected Attributes

static bool do_throw
 throw option More...
 

Detailed Description

template<class T>
class JLANG::JGZFileReader< T >

Object reading from gzipped file.

This class implements the JAccessibleObjectIterator interface.

Definition at line 28 of file JGZFileReader.hh.

Member Typedef Documentation

template<class T>
typedef JObjectIterator<T>::pointer_type JLANG::JAbstractObjectIterator< T >::pointer_type
inherited

Definition at line 39 of file JAbstractObjectIterator.hh.

Constructor & Destructor Documentation

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

Default constructor.

Definition at line 37 of file JGZFileReader.hh.

37  :
38  igzstream(),
39  JStreamObjectIterator<T>(static_cast<std::istream&>(*this))
40  {}
igzstream()
Definition: gzstream.h:205
template<class T >
JLANG::JGZFileReader< T >::JGZFileReader ( const char *  file_name)
inline

Constructor.

Parameters
file_namefile name

Definition at line 48 of file JGZFileReader.hh.

48  :
49  JAccessible(),
50  igzstream(file_name),
51  JStreamObjectIterator<T>(static_cast<std::istream&>(*this))
52  {}
igzstream()
Definition: gzstream.h:205
JAccessible()
Default constructor.
Definition: JAccessible.hh:27

Member Function Documentation

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

Check is file is open.

Returns
true if open; else false

Implements JLANG::JAccessible.

Definition at line 60 of file JGZFileReader.hh.

61  {
62  return igzstream::is_open();
63  }
bool is_open() const
Definition: gzstream.h:194
template<class T >
virtual void JLANG::JGZFileReader< T >::open ( const char *  file_name)
inlineoverridevirtual

Open file.

Parameters
file_namefile name

Implements JLANG::JAccessible.

Definition at line 71 of file JGZFileReader.hh.

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  }
Exception for opening of file.
Definition: JException.hh:342
virtual bool is_open() const override
Check is file is open.
void open(const char *name, int open_mode=std::ios::in)
Definition: gzstream.h:208
static void Throw(const bool option)
Enable/disable throw option.
Definition: JThrow.hh:37
template<class T >
virtual void JLANG::JGZFileReader< T >::close ( )
inlineoverridevirtual

Close file.

Implements JLANG::JAccessible.

Definition at line 84 of file JGZFileReader.hh.

85  {
87  }
void close()
Definition: gzstream.h:185
void igzstream::open ( const char *  name,
int  open_mode = std::ios::in 
)
inlineinherited

Definition at line 208 of file gzstream.h.

208  {
209  gzstreambase::open( name, open_mode);
210  }
then echo Enter input within $TIMEOUT_S seconds echo n User name
Definition: JCookie.sh:42
void open(const char *name, int open_mode)
Definition: gzstream.h:180
gzstreambuf* gzstreambase::rdbuf ( )
inlineinherited

Definition at line 193 of file gzstream.h.

193 { return &buf; }
gzstreambuf buf
Definition: gzstream.h:169
template<class T >
virtual bool JLANG::JStreamObjectIterator< T >::setObject ( T object)
inlineoverridevirtualinherited

Set object.

Parameters
objectreference to object to be set
Returns
true if set; else false

Implements JLANG::JAbstractObjectIterator< T >.

Definition at line 45 of file JStreamObjectIterator.hh.

46  {
47  return (bool) (__in && __in >> object);
48  }
template<class T>
virtual bool JLANG::JAbstractObjectIterator< T >::hasNext ( )
inlineoverridevirtualinherited

Check availability of next element.

Returns
true if the iteration has more elements; else false

Implements JLANG::JObjectIterator< T >.

Definition at line 56 of file JAbstractObjectIterator.hh.

57  {
58  if (!has_next) {
59  has_next = this->setObject(object);
60  }
61 
62  return has_next;
63  }
virtual bool setObject(T &object)=0
Set object.
template<class T>
virtual const pointer_type& JLANG::JAbstractObjectIterator< T >::next ( )
inlineoverridevirtualinherited

Get next element.

Returns
pointer to element

Implements JLANG::JObjectIterator< T >.

Definition at line 71 of file JAbstractObjectIterator.hh.

72  {
73  if (has_next)
74  ps.reset(&this->object);
75  else
76  ps.reset(NULL);
77 
78  has_next = false;
79 
80  return ps;
81  }
virtual void reset() override
Reset pointer.
Definition: JPointer.hh:84
template<class T>
virtual skip_type JLANG::JObjectIterator< T >::skip ( const skip_type  ns)
inlinevirtualinherited

Skip items.

Parameters
nsnumber of items to skip
Returns
number of items skipped

Reimplemented in JLANG::JPipe< T >, JLANG::JPipe< JTail_t >, JLANG::JPipe< JHead_t >, JLANG::JSTDObjectIterator< T >, JLANG::JAbstractObjectReader< T >, JLANG::JAbstractObjectReader< JNullType >, JLANG::JAbstractObjectReader< const T >, JLANG::JAbstractObjectReader< JTail_t >, JLANG::JAbstractObjectReader< JHead_t >, JLANG::JAbstractObjectReader< KM3NETDAQ::KM3NETDAQ::JDAQEvent >, and JLANG::JAbstractObjectReader< JDAQSummaryslice >.

Definition at line 90 of file JObjectIterator.hh.

91  {
92  skip_type i = 0;
93 
94  for ( ; i != ns && hasNext(); ++i) {
95  next();
96  }
97 
98  return i;
99  }
unsigned int skip_type
Type definition for number of objects to skip.
virtual const pointer_type & next()=0
Get next element.
virtual bool hasNext()=0
Check availability of next element.
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  }
static bool do_throw
throw option
Definition: JThrow.hh:28
static int JLANG::JThrow< JAccessible >::Throw ( const JException error,
const int  value = -1 
)
inlinestaticinherited

Throw exception or return error.

Parameters
errorexception
valuereturn code
Returns
return code

Definition at line 50 of file JThrow.hh.

51  {
52  using namespace std;
53 
54  if (do_throw) {
55  throw error;
56  }
57 
58  cerr << error.what() << endl;
59 
60  return value;
61  }
virtual const char * what() const override
Get error message.
Definition: JException.hh:48
static bool do_throw
throw option
Definition: JThrow.hh:28

Member Data Documentation

gzstreambuf gzstreambase::buf
protectedinherited

Definition at line 169 of file gzstream.h.

template<class T >
std::istream& JLANG::JStreamObjectIterator< T >::__in
protectedinherited

Definition at line 51 of file JStreamObjectIterator.hh.

template<class T>
T JLANG::JAbstractObjectIterator< T >::object
protectedinherited

object

Definition at line 34 of file JAbstractObjectIterator.hh.

template<class T>
bool JLANG::JAbstractObjectIterator< T >::has_next
protectedinherited

status

Definition at line 35 of file JAbstractObjectIterator.hh.

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: