aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/jinja2cpp/src/generic_list.cpp
blob: 883ef3615ad6feea411632ec15865a1cc7565173 (plain) (blame)
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
#include <jinja2cpp/generic_list.h>
#include <jinja2cpp/generic_list_iterator.h>

namespace jinja2 {

detail::GenericListIterator GenericList::begin() const
{
    return m_accessor && m_accessor() ? detail::GenericListIterator(m_accessor()->CreateEnumerator()) : detail::GenericListIterator();
}

detail::GenericListIterator GenericList::end() const
{
    return detail::GenericListIterator();
}

auto GenericList::cbegin() const {return begin();}
auto GenericList::cend() const {return end();}

bool GenericList::IsEqual(const GenericList& rhs) const
{
    if (IsValid() && rhs.IsValid() && !GetAccessor()->IsEqual(*rhs.GetAccessor()))
        return false;
    if ((IsValid() && !rhs.IsValid()) || (!IsValid() && rhs.IsValid()))
            return false;
    return true;
}

bool operator==(const GenericList& lhs, const GenericList& rhs)
{
    return lhs.IsEqual(rhs);
}

bool operator!=(const GenericList& lhs, const GenericList& rhs)
{
    return !(lhs == rhs);
}

} // namespace jinja2