diff options
Diffstat (limited to 'zend/invaliditerator.h')
-rw-r--r-- | zend/invaliditerator.h | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/zend/invaliditerator.h b/zend/invaliditerator.h new file mode 100644 index 0000000..388eca8 --- /dev/null +++ b/zend/invaliditerator.h @@ -0,0 +1,82 @@ +/** + * InvalidIterator.h + * + * Iterator class that is used for value objects that are not even + * iteratable. + * + * @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com> + * @copyright 2014 Copernica BV + */ + +/** + * Set up namespace + */ +namespace Php { + +/** + * Class definition + */ +class InvalidIterator : public ValueIteratorImpl +{ +public: + /** + * Clone the object + * @param tsrm_ls + * @return ValueIteratorImpl + */ + virtual ValueIteratorImpl *clone() + { + // create a new instance + return new InvalidIterator(*this); + } + + /** + * Increment position (pre-increment) + * @param tsrm_ls + * @return bool + */ + virtual bool increment() override + { + return false; + } + + /** + * Decrement position (pre-decrement) + * @return bool + */ + virtual bool decrement() override + { + return false; + } + + /** + * Compare with other iterator + * @param that + * @return bool + */ + virtual bool equals(const ValueIteratorImpl *that) const override + { + // the other iterator is also an invalid-iterator, and all invalid + // iterators are equal + return true; + } + + /** + * Derefecence, this returns a std::pair with the current key and value + * @return std::pair + */ + virtual const std::pair<Value,Value> ¤t() const override + { + // this method is never called, when it is, we create a static instance + static std::pair<Value,Value> result; + + // return it + return result; + } +}; + +/** + * End namespace + */ +} + |