summaryrefslogtreecommitdiff
path: root/zend/invaliditerator.h
blob: 388eca8e6f0d865c09070fae6c112f4731721d5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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> &current() 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
 */
}