- Fix TriBool usage in Resolver.
[platform/upstream/libzypp.git] / zypp / TriBool.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/TriBool.h
10  *
11 */
12 #ifndef ZYPP_TRIBOOL_H
13 #define ZYPP_TRIBOOL_H
14
15 #include <iosfwd>
16 #include <boost/logic/tribool.hpp>
17
18 ///////////////////////////////////////////////////////////////////
19 namespace zypp
20 { /////////////////////////////////////////////////////////////////
21
22   /** 3-state boolean logic (\c true, \c false and \c indeterminate).
23    * \code
24    * namespace zypp
25    * {
26    *   typedef boost::logic::tribool TriBool;
27    *   using   boost::logic::tribool;
28    *   using   boost::logic::indeterminate;
29    * }
30    * \endcode
31    *
32    * \warning Be carefull.esp. when comparing \ref TriBool using
33    * \c operator==, as <b><tt>( indeterminate == indeterminate )</tt></b>
34    * does \b not evaluate \b true. It's \c indeterminate.
35    *
36    * \see http://www.boost.org/doc/html/tribool.html
37    * \ingroup BOOST
38   */
39   typedef boost::logic::tribool TriBool;
40   using   boost::logic::tribool;
41   using   boost::logic::indeterminate;
42
43   /////////////////////////////////////////////////////////////////
44 } // namespace zypp
45 ///////////////////////////////////////////////////////////////////
46 namespace boost
47 {
48     namespace logic
49     {
50       /** \relates TriBool stream output */
51       inline std::ostream & operator<<(std::ostream & s, const tribool & obj)
52       {
53         if (indeterminate(obj))
54           s << "indeterminate";
55         else if (obj)
56           s << "true";
57         else
58           s << "false";
59         return s;
60       }
61     }
62 }
63 #endif // ZYPP_TRIBOOL_H