Jpp  master_rocky-40-g5f0272dcd
the software that should make you happy
Public Types | Public Member Functions | Protected Attributes | Private Attributes | List of all members
JLANG::JStreamObjectIterator< T > Class Template Reference

Stream object iterator. More...

#include <JStreamObjectIterator.hh>

Inheritance diagram for JLANG::JStreamObjectIterator< T >:
JLANG::JAbstractObjectIterator< T > JLANG::JObjectIterator< T > JLANG::JASCIIFileReader< T > JLANG::JGZFileReader< T >

Public Types

typedef JObjectIterator< T >::pointer_type pointer_type
 

Public Member Functions

 JStreamObjectIterator (std::istream &in)
 Constructor. More...
 
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...
 

Protected Attributes

std::istream & __in
 
object
 object More...
 
bool has_next
 status More...
 

Private Attributes

pointer_type ps
 

Detailed Description

template<class T>
class JLANG::JStreamObjectIterator< T >

Stream object iterator.

This class implements the JAbstractObjectIterator interface.

Definition at line 25 of file JStreamObjectIterator.hh.

Member Typedef Documentation

◆ pointer_type

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

◆ JStreamObjectIterator()

template<class T >
JLANG::JStreamObjectIterator< T >::JStreamObjectIterator ( std::istream &  in)
inline

Constructor.

Parameters
ininput stream

Definition at line 34 of file JStreamObjectIterator.hh.

34  :
35  __in(in)
36  {}

Member Function Documentation

◆ setObject()

template<class T >
virtual bool JLANG::JStreamObjectIterator< T >::setObject ( T &  object)
inlineoverridevirtual

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  }

◆ hasNext()

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.

◆ next()

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

◆ skip()

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::JSTDObjectIterator< T >, JLANG::JPipe< T >, JLANG::JPipe< JTail_t >, JLANG::JPipe< JHead_t >, and JLANG::JAbstractObjectReader< T >.

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  }
virtual const pointer_type & next()=0
Get next element.
virtual bool hasNext()=0
Check availability of next element.
unsigned int skip_type
Type definition for number of objects to skip.
std::vector< size_t > ns

Member Data Documentation

◆ __in

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

Definition at line 51 of file JStreamObjectIterator.hh.

◆ object

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

object

Definition at line 34 of file JAbstractObjectIterator.hh.

◆ has_next

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

status

Definition at line 35 of file JAbstractObjectIterator.hh.

◆ ps

template<class T >
pointer_type JLANG::JAbstractObjectIterator< T >::ps
privateinherited

Definition at line 84 of file JAbstractObjectIterator.hh.


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