Commit | Line | Data |
---|---|---|
0e23f538 TJ |
1 | /* |
2 | The software in this package is distributed under the GNU General | |
3 | Public License version 2 (with a special exception described below). | |
4 | ||
5 | A copy of GNU General Public License (GPL) is included in this distribution, | |
6 | in the file COPYING.GPL. | |
7 | ||
8 | As a special exception, if other files instantiate templates or use macros | |
9 | or inline functions from this file, or you compile this file and link it | |
10 | with other works to produce a work based on this file, this file | |
11 | does not by itself cause the resulting work to be covered | |
12 | by the GNU General Public License. | |
13 | ||
14 | However the source code for this file must still be made available | |
15 | in accordance with section (3) of the GNU General Public License. | |
16 | ||
17 | This exception does not invalidate any other reasons why a work based | |
18 | on this file might be covered by the GNU General Public License. | |
19 | */ | |
49f91b40 TJ |
20 | /** @file |
21 | * @brief Implementation of intuitive tristate logic | |
22 | * | |
23 | * (c) Copyright 2011 by Intra2net AG | |
24 | * Written by Erich Willems and Thomas Jarosch | |
25 | * | |
26 | * After we had serious trouble with the current boost::logic::tribool implementation | |
27 | * overloading the comparison operators, we rolled our own class. | |
49f91b40 TJ |
28 | */ |
29 | ||
30 | namespace I2n | |
31 | { | |
32 | ||
33 | class Tribool | |
34 | { | |
35 | public: | |
36 | enum State { False, True, Undef }; | |
37 | ||
38 | Tribool(); | |
39 | Tribool(const State &v); | |
40 | Tribool(const Tribool& src); | |
41 | ||
42 | // set element | |
43 | Tribool& operator= (const State &v); | |
44 | Tribool& operator= (const Tribool& src); | |
45 | ||
46 | // Element comparison | |
47 | bool operator==(const Tribool& v) const; | |
48 | bool operator!=(const Tribool& v) const; | |
49 | ||
50 | // logic operators | |
51 | Tribool operator !() const; | |
52 | Tribool operator ||(const Tribool& x) const; | |
53 | Tribool operator &&(const Tribool& x) const; | |
54 | ||
55 | // Bistate logic to tristate conversion | |
56 | Tribool(const bool &v); | |
57 | Tribool& operator= (const bool &v); | |
58 | ||
59 | // comparision with bool (bi) | |
60 | bool is_exact(const bool &v) const; | |
61 | ||
62 | private: | |
63 | State Value; | |
64 | }; | |
65 | ||
66 | } |