blob: 068a4a8a01b34d399fdba191008fa3b19f3531f8 (
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
|
class CapMatch
{
enum Result { NOMATCH, MATCH, IRRELEVANT };
public:
CapMatch( bool val_r )
: _result( val_r ? MATCH : NOMATCH )
{}
static const CapMatch yes;
static const CapMatch no;
static const CapMatch irrelevant;
friend bool operator==( const CapMatch & lhs, const CapMatch & rhs )
{ return lhs._result == rhs._result; }
friend bool operator!=( const CapMatch & lhs, const CapMatch & rhs )
{ return lhs._result != rhs._result; }
friend CapMatch operator!( const CapMatch & lhs )
{
if ( lhs._result == CapMatch::IRRELEVANT )
return lhs;
return !(lhs._result == CapMatch::MATCH);
}
friend CapMatch operator&&( const CapMatch & lhs, const CapMatch & rhs )
{
if ( lhs._result == CapMatch::IRRELEVANT )
return rhs;
if ( rhs._result == CapMatch::IRRELEVANT )
return lhs;
return (lhs._result == CapMatch::MATCH)
&& (rhs._result == CapMatch::MATCH);
}
friend CapMatch operator||( const CapMatch & lhs, const CapMatch & rhs )
{
if ( lhs._result == CapMatch::IRRELEVANT )
return rhs;
if ( rhs._result == CapMatch::IRRELEVANT )
return lhs;
return (lhs._result == CapMatch::MATCH)
|| (rhs._result == CapMatch::MATCH);
}
friend std::ostream & operator<<( std::ostream & str, const CapMatch & obj );
private:
CapMatch()
: _result( IRRELEVANT )
{}
Result _result;
};
|