Switch license from Intranator license to GPLv2 + linking exception (ACKed by Steffen)
[libi2ncommon] / src / tribool.hpp
CommitLineData
0e23f538
TJ
1/*
2The software in this package is distributed under the GNU General
3Public License version 2 (with a special exception described below).
4
5A copy of GNU General Public License (GPL) is included in this distribution,
6in the file COPYING.GPL.
7
8As a special exception, if other files instantiate templates or use macros
9or inline functions from this file, or you compile this file and link it
10with other works to produce a work based on this file, this file
11does not by itself cause the resulting work to be covered
12by the GNU General Public License.
13
14However the source code for this file must still be made available
15in accordance with section (3) of the GNU General Public License.
16
17This exception does not invalidate any other reasons why a work based
18on 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
30namespace I2n
31{
32
33class Tribool
34{
35public:
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
62private:
63 State Value;
64};
65
66}