~thopiekar/zypper/libzypp-manual-import

« back to all changes in this revision

Viewing changes to zypp/TriBool.h

  • Committer: Thomas-Karl Pietrowski
  • Date: 2015-08-15 15:59:50 UTC
  • Revision ID: thopiekar@googlemail.com-20150815155950-j66qn38efmvn289t
syncing with "changes 15.13.0 (11)"  #9a0aca7e3a21d768491b141a8ae86ef0c3fbc227
* https://github.com/openSUSE/libzypp/commit/9a0aca7e3a21d768491b141a8ae86ef0c3fbc227

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
#define ZYPP_TRIBOOL_H
14
14
 
15
15
#include <iosfwd>
 
16
#include <string>
16
17
#include <boost/logic/tribool.hpp>
17
18
 
18
19
///////////////////////////////////////////////////////////////////
40
41
  using   boost::logic::tribool;
41
42
  using   boost::logic::indeterminate;
42
43
 
 
44
  inline std::string asString( const TriBool & val_r, const std::string & istr_r = std::string(),
 
45
                                                      const std::string & tstr_r = std::string(),
 
46
                                                      const std::string & fstr_r = std::string() )
 
47
  {
 
48
    std::string ret;
 
49
    if (indeterminate(val_r))
 
50
      ret = ( istr_r.empty() ? "indeterminate" : istr_r );
 
51
    else if (val_r)
 
52
      ret = ( tstr_r.empty() ? "true" : tstr_r );
 
53
    else
 
54
      ret = ( fstr_r.empty() ? "false" : fstr_r );
 
55
    return ret;
 
56
  }
 
57
 
43
58
  /////////////////////////////////////////////////////////////////
44
59
} // namespace zypp
45
60
///////////////////////////////////////////////////////////////////
49
64
    {
50
65
      /** \relates TriBool stream output */
51
66
      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
 
      }
 
67
      { return s << zypp::asString( obj ); }
61
68
    }
62
69
}
63
70
#endif // ZYPP_TRIBOOL_H