Om
stream_source.cpp
Go to the documentation of this file.
1 
15 #ifndef Om_Source_StreamSource_
16 
18 
19 #else
20 
21 // MARK: - Om::Source::StreamSource
22 
23  #define Template_ \
24  template <typename ThisItem>
25 
26  #define Type_ \
27  Om::Source::StreamSource<ThisItem>
28 
29 // MARK: public (non-static)
30 
31 Template_
32 inline Type_::StreamSource():
33 thisStreamIterator(),
34 thisItem() {}
35 
36 Template_
37 inline Type_::StreamSource(std::istream & theStream):
38 thisStreamIterator(theStream),
39 thisItem() {}
40 
41 Template_
42 inline Type_ & Type_::operator =(StreamSource theStreamSource) {
43  this->Swap(theStreamSource);
44  return *this;
45 }
46 
47 Template_
48 inline bool Type_::operator !() const {
49  return StreamIterator() == this->thisStreamIterator;
50 }
51 
52 Template_
53 inline ThisItem const & Type_::operator *() const {
54  assert(
55  StreamIterator() != this->thisStreamIterator
56  );
57  this->thisItem = *this->thisStreamIterator;
58  return *this->thisItem;
59 }
60 
61 Template_
62 inline bool Type_::Equals(StreamSource const & theStreamSource) const {
63  return this->thisStreamIterator == theStreamSource.thisStreamIterator;
64 }
65 
66 Template_
67 inline void Type_::Pop() {
68  assert(
69  StreamIterator() != this->thisStreamIterator
70  );
71  ++this->thisStreamIterator;
72 }
73 
74 Template_
75 inline void Type_::Swap(StreamSource & theStreamSource) {
77  this->thisStreamIterator,
78  theStreamSource.thisStreamIterator
79  );
80  this->thisItem.swap(theStreamSource.thisItem);
81 }
82 
83  #undef Type_
84  #undef Template_
85 
86 // MARK: - Om::Source::
87 
88  #define Template_ \
89  template <typename TheItem>
90 
91  #define Type_ \
92  Om::Source::StreamSource<TheItem>
93 
94 Template_
95 inline bool Om::Source::operator ==(
96  Type_ const & theFirst,
97  Type_ const & theSecond
98 ) {
99  return theFirst.Equals(theSecond);
100 }
101 
102 Template_
103 inline bool Om::Source::operator !=(
104  Type_ const & theFirst,
105  Type_ const & theSecond
106 ) {
107  return !theFirst.Equals(theSecond);
108 }
109 
110 // MARK: - boost::
111 
112 Template_
113 inline void boost::swap(
114  Type_ & theFirst,
115  Type_ & theSecond
116 ) {
117  theFirst.Swap(theSecond);
118 }
119 
120  #undef Type_
121  #undef Template_
122 
123 #endif
bool operator==(CodePointSource< TheCodeUnitIterator > const &, CodePointSource< TheCodeUnitIterator > const &)
bool operator!=(CodePointSource< TheCodeUnitIterator > const &, CodePointSource< TheCodeUnitIterator > const &)
void swap(Om::Language::Expression &, Om::Language::Expression &)
Om header file.