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 
5 #include "binary_ofstream.h"
6 #include <iterator>
8 
9 template <typename T>
10 class bistream_iterator : public std::iterator<std::input_iterator_tag, T, ptrdiff_t, const T*, const T&> {
11 public:
13 
14  bistream_iterator(binary_ifstream& s) : stream_(&s) { read(); }
15 
16  const T& operator*() const { return value_; }
17 
18  const T* operator->() const { return &value_; }
19 
21  read();
22  return *this;
23  }
24 
27  read();
28  return tmp;
29  }
30 
31  bool operator==(const bistream_iterator& rhs) { return stream_ == rhs.stream_; }
32 
33  bool operator!=(const bistream_iterator& rhs) { return !operator==(rhs); }
34 
35 private:
36  binary_ifstream* stream_;
38 
39  void read() {
40  if (stream_ != 0) {
41  // if (!(*stream_ >> value_)) stream_ = 0;
42  if (!(*stream_ >> value_)) {
43  stream_ = 0;
44  // std::cout << "istream_iterator: stream turned bad, set stream_ to zero" << std::endl;
45  }
46  }
47  }
48 };
49 
50 template <typename T>
51 class dso_internal bostream_iterator : public std::iterator<std::output_iterator_tag, void, void, void, void> {
52 public:
54 
56  *stream_ << t;
57  return *this;
58  }
59 
60  bostream_iterator& operator*() { return *this; }
61  bostream_iterator& operator++() { return *this; }
62  bostream_iterator& operator++(int) { return *this; }
63 
64 private:
66 };
67 
68 #endif
bostream_iterator & operator++(int)
bool operator!=(const bistream_iterator &rhs)
bostream_iterator & operator=(const T &t)
bistream_iterator & operator++(int)
bostream_iterator & operator++()
binary_ifstream * stream_
#define dso_internal
Definition: Visibility.h:13
bostream_iterator & operator*()
binary_ofstream * stream_
const T & operator*() const
tmp
align.sh
Definition: createJobs.py:716
long double T
bistream_iterator(binary_ifstream &s)
bistream_iterator & operator++()
bool operator==(const bistream_iterator &rhs)
bostream_iterator(binary_ofstream &s)
const T * operator->() const