Om
iterator_pair_source.cpp
Go to the documentation of this file.
1 
15 #ifndef Om_Source_IteratorPairSource_
16 
18 
19 #else
20 
21 // MARK: - Om::Source::IteratorPairSource
22 
23  #define Template_ \
24  template < \
25  typename ThisItem, \
26  typename ThisIterator \
27  >
28 
29  #define Type_ \
30  Om::Source::IteratorPairSource< \
31  ThisItem, \
32  ThisIterator \
33  >
34 
35 // MARK: public (non-static)
36 
37 Template_
38 inline Type_::IteratorPairSource(
39  ThisIterator theCurrent,
40  ThisIterator const theEnd
41 ):
42 thisCurrent(theCurrent),
43 thisEnd(theEnd) {}
44 
45 Template_
46 inline Type_ & Type_::operator =(IteratorPairSource theIteratorPairSource) {
47  this->Swap(theIteratorPairSource);
48  return *this;
49 }
50 
51 Template_
52 inline bool Type_::operator !() const {
53  return this->thisEnd == this->thisCurrent;
54 }
55 
56 Template_
57 inline ThisItem & Type_::operator *() const {
58  assert(this->thisEnd != this->thisCurrent);
59  return *this->thisCurrent;
60 }
61 
62 Template_
63 inline bool Type_::Equals(IteratorPairSource const & theIteratorPairSource) const {
64  return this->thisCurrent == theIteratorPairSource.thisCurrent;
65 }
66 
67 Template_
68 inline void Type_::End() {
69  this->thisCurrent = this->thisEnd;
70 }
71 
72 Template_
73 inline void Type_::Pop() {
74  assert(this->thisEnd != this->thisCurrent);
75  ++this->thisCurrent;
76 }
77 
78 Template_
79 inline void Type_::Swap(IteratorPairSource & theIteratorPairSource) {
81  this->thisCurrent,
82  theIteratorPairSource.thisCurrent
83  );
85  this->thisEnd,
86  theIteratorPairSource.thisEnd
87  );
88 }
89 
90  #undef Type_
91  #undef Template_
92 
93 // MARK: - Om::Source::
94 
95  #define Template_ \
96  template < \
97  typename TheItem, \
98  typename TheIterator \
99  >
100 
101  #define Type_ \
102  Om::Source::IteratorPairSource< \
103  TheItem, \
104  TheIterator \
105  >
106 
107 Template_
108 inline bool Om::Source::operator ==(
109  Type_ const & theFirst,
110  Type_ const & theSecond
111 ) {
112  return theFirst.Equals(theSecond);
113 }
114 
115 Template_
116 inline bool Om::Source::operator !=(
117  Type_ const & theFirst,
118  Type_ const & theSecond
119 ) {
120  return !theFirst.Equals(theSecond);
121 }
122 
123 // MARK: - boost::
124 
125 Template_
126 inline void boost::swap(
127  Type_ & theFirst,
128  Type_ & theSecond
129 ) {
130  theFirst.Swap(theSecond);
131 }
132 
133  #undef Type_
134  #undef Template_
135 
136 #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 &)