CMS 3D CMS Logo

bstream_iterator.h
Go to the documentation of this file.
1 #ifndef bstream_iterator_H
2 #define bstream_iterator_H
3 
4 #include "binary_ifstream.h"
5 #include "binary_ofstream.h"
6 #include <iterator>
8 
9 template <typename T>
11  public std::iterator<std::input_iterator_tag, T, ptrdiff_t, const T*, const T&>
12 {
13 public:
14 
16 
18  read();
19  }
20 
21  const T& operator*() const {return value_;}
22 
23  const T* operator->() const {return &value_;}
24 
25  bistream_iterator& operator++() {read(); return *this;}
26 
29  read();
30  return tmp;
31  }
32 
33  bool operator==(const bistream_iterator& rhs) {
34  return stream_ == rhs.stream_;
35  }
36 
37  bool operator!=(const bistream_iterator& rhs) {
38  return !operator==(rhs);
39  }
40 
41 private:
42 
45 
46  void read() {
47  if (stream_ != 0) {
48  // if (!(*stream_ >> value_)) stream_ = 0;
49  if (!(*stream_ >> value_)) {
50  stream_ = 0;
51  // std::cout << "istream_iterator: stream turned bad, set stream_ to zero" << std::endl;
52  }
53  }
54  }
55 
56 };
57 
58 template <typename T>
60  public std::iterator<std::output_iterator_tag,void,void,void,void> {
61 public:
62 
64 
66  *stream_ << t;
67  return *this;
68  }
69 
70  bostream_iterator& operator*() {return *this;}
71  bostream_iterator& operator++() {return *this;}
72  bostream_iterator& operator++(int) {return *this;}
73 
74 private:
75 
77 
78 };
79 
80 #endif
bostream_iterator::operator++
bostream_iterator & operator++(int)
Definition: bstream_iterator.h:72
Visibility.h
bistream_iterator::operator==
bool operator==(const bistream_iterator &rhs)
Definition: bstream_iterator.h:33
bistream_iterator::stream_
binary_ifstream * stream_
Definition: bstream_iterator.h:43
bistream_iterator::operator++
bistream_iterator & operator++()
Definition: bstream_iterator.h:25
bistream_iterator::bistream_iterator
bistream_iterator()
Definition: bstream_iterator.h:15
bistream_iterator::read
void read()
Definition: bstream_iterator.h:46
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
bistream_iterator::bistream_iterator
bistream_iterator(binary_ifstream &s)
Definition: bstream_iterator.h:17
bistream_iterator::operator!=
bool operator!=(const bistream_iterator &rhs)
Definition: bstream_iterator.h:37
alignCSCRings.s
s
Definition: alignCSCRings.py:92
bistream_iterator::operator*
const T & operator*() const
Definition: bstream_iterator.h:21
binary_ofstream.h
bostream_iterator::operator*
bostream_iterator & operator*()
Definition: bstream_iterator.h:70
binary_ifstream
Definition: binary_ifstream.h:8
bistream_iterator::operator++
bistream_iterator & operator++(int)
Definition: bstream_iterator.h:27
OrderedSet.t
t
Definition: OrderedSet.py:90
bistream_iterator::value_
T value_
Definition: bstream_iterator.h:44
bostream_iterator
Definition: bstream_iterator.h:59
bistream_iterator::operator->
const T * operator->() const
Definition: bstream_iterator.h:23
binary_ifstream.h
dso_internal
#define dso_internal
Definition: Visibility.h:13
bostream_iterator::stream_
binary_ofstream * stream_
Definition: bstream_iterator.h:76
binary_ofstream
Definition: binary_ofstream.h:8
T
long double T
Definition: Basic3DVectorLD.h:48
bostream_iterator::operator=
bostream_iterator & operator=(const T &t)
Definition: bstream_iterator.h:65
bostream_iterator::operator++
bostream_iterator & operator++()
Definition: bstream_iterator.h:71
bistream_iterator
Definition: bstream_iterator.h:10
bostream_iterator::bostream_iterator
bostream_iterator(binary_ofstream &s)
Definition: bstream_iterator.h:63