diff --git a/Foundation/include/Poco/Dynamic/VarIterator.h b/Foundation/include/Poco/Dynamic/VarIterator.h index eb9129fbc..ebf6c0853 100644 --- a/Foundation/include/Poco/Dynamic/VarIterator.h +++ b/Foundation/include/Poco/Dynamic/VarIterator.h @@ -69,6 +69,18 @@ public: bool operator != (const VarIterator& other) const; /// Inequality operator. + bool operator < (const VarIterator& other) const; + /// Less than operator. + + bool operator > (const VarIterator& other) const; + /// Greater than operator. + + bool operator <= (const VarIterator& other) const; + /// Less than or equal to operator. + + bool operator >= (const VarIterator& other) const; + /// Greater than or equal to operator. + Var& operator * () const; /// Returns value at the current position. @@ -138,6 +150,30 @@ inline bool VarIterator::operator != (const VarIterator& other) const } +inline bool VarIterator::operator < (const VarIterator& other) const +{ + return _position < other._position; +} + + +inline bool VarIterator::operator > (const VarIterator& other) const +{ + return _position > other._position; +} + + +inline bool VarIterator::operator <= (const VarIterator& other) const +{ + return _position <= other._position; +} + + +inline bool VarIterator::operator >= (const VarIterator& other) const +{ + return _position >= other._position; +} + + } } // namespace Poco::Dynamic diff --git a/Foundation/src/VarIterator.cpp b/Foundation/src/VarIterator.cpp index f4f66e395..cd4161aac 100644 --- a/Foundation/src/VarIterator.cpp +++ b/Foundation/src/VarIterator.cpp @@ -83,8 +83,7 @@ void VarIterator::increment() const { if (POSITION_END == _position) throw RangeException("End of iterator reached."); - - if (_position < _pVar->size() - 1) + else if (_position < _pVar->size() - 1) ++_position; else _position = POSITION_END; diff --git a/Foundation/testsuite/src/VarTest.cpp b/Foundation/testsuite/src/VarTest.cpp index 7b56545c9..c05ce734e 100644 --- a/Foundation/testsuite/src/VarTest.cpp +++ b/Foundation/testsuite/src/VarTest.cpp @@ -3161,6 +3161,8 @@ void VarTest::testIterator() da = Poco::Dynamic::Array(); assertTrue(da.begin() == da.end()); + assertTrue(da.begin() <= da.end()); + assertTrue(da.begin() >= da.end()); da = 1; assertTrue (!da.isEmpty()); @@ -3172,6 +3174,10 @@ void VarTest::testIterator() } catch (RangeException&) {} assertTrue (da.begin() != da.end()); + assertTrue (da.begin() <= da.end()); + assertTrue (da.begin() < da.end()); + assertTrue (da.end() >= da.begin()); + assertTrue (da.end() > da.begin()); Var::Iterator it = da.begin(); Var::Iterator end = da.end();