2 The software in this package is distributed under the GNU General
3 Public License version 2 (with a special exception described below).
5 A copy of GNU General Public License (GPL) is included in this distribution,
6 in the file COPYING.GPL.
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.
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.
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.
21 * @brief Implementation of intuitive tristate logic
23 * (c) Copyright 2011 by Intra2net AG
24 * Written by Erich Willems and Thomas Jarosch
26 * After we had serious trouble with the current boost::logic::tribool implementation
27 * overloading the comparison operators, we rolled our own class.
41 enum State { False, True, Undef };
44 Tribool(const State &v);
45 Tribool(const Tribool& src);
48 Tribool& operator= (const State &v);
49 Tribool& operator= (const Tribool& src);
52 bool operator==(const Tribool& v) const;
53 bool operator!=(const Tribool& v) const;
56 Tribool operator !() const;
57 Tribool operator ||(const Tribool& x) const;
58 Tribool operator &&(const Tribool& x) const;
60 // Bistate logic to tristate conversion
61 Tribool(const bool &v);
62 Tribool& operator= (const bool &v);
64 // comparision with bool (bi)
65 bool is_exact(const bool &v) const;
76 // allow Tribools to be easily printed to ostreams
77 template <class charT, class traits>
78 inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& os,
79 const I2n::Tribool& x)
81 if (x == I2n::Tribool::False)
83 else if (x == I2n::Tribool::True)