aboutsummaryrefslogtreecommitdiffstats
path: root/document/src/vespa/document/select/result.cpp
blob: e832bfde3aa9d4b61fbd4c32c95d2f5623d3d07c (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
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "result.h"
#include <ostream>

namespace document::select {

Result Result::Invalid;
Result Result::False;
Result Result::True;

Result::Result() = default;

const Result&
Result::operator!() const {
    if (this == &Invalid) {
        return Invalid;
    }
    return (this == &True ? False : True);
}

const Result&
Result::operator&&(const Result& r) const {
    if (this == &False || &r == &False) {
        return False;
    }
    return (this == &True && &r == &True ? True : Invalid);
}

const Result&
Result::operator||(const Result& r) const {
    if (this == &True || &r == &True) {
        return True;
    }
    if (this == &Invalid || &r == &Invalid) {
        return Invalid;
    }
    return False;
}

void
Result::print(std::ostream& out, bool,
              const std::string&) const
{
    if (this == &Invalid) out << "Invalid";
    else if (this == &True) out << "True";
    else out << "False";
}

}