From: Michael Andres Date: Wed, 28 Nov 2007 16:44:01 +0000 (+0000) Subject: Support libsatsolver compatible Rel construction and conversion from/to unsigned. X-Git-Tag: 6.6.0~1481 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ebfc066d52d36e97ca058b2071d692cd62687ece;p=platform%2Fupstream%2Flibzypp.git Support libsatsolver compatible Rel construction and conversion from/to unsigned. --- diff --git a/zypp/Rel.h b/zypp/Rel.h index 0779ba9e2..d3aa96fec 100644 --- a/zypp/Rel.h +++ b/zypp/Rel.h @@ -59,8 +59,19 @@ namespace zypp /** Enumarators provided \b only for use \ref inSwitch statement. * \see inSwitch + * \note Enumarator values also correspond to the values libsatsolver + * uses to encode these relations. */ - enum for_use_in_switch { EQ_e, NE_e, LT_e, LE_e, GT_e, GE_e, ANY_e, NONE_e }; + enum for_use_in_switch { + NONE_e = 0U, + GT_e = 1U, + EQ_e = 2U, + LT_e = 4U, + GE_e = GT_e|EQ_e, + LE_e = LT_e|EQ_e, + NE_e = GT_e|LT_e, + ANY_e = GT_e|EQ_e|LT_e, + }; /** DefaultCtor ANY. */ Rel() @@ -80,6 +91,12 @@ namespace zypp explicit Rel( const std::string & strval_r ); + /** Ctor from bits. */ + explicit + Rel( unsigned bits_r ) + : _op( for_use_in_switch(bits_r & ANY_e) ) + {} + /** String representation of relational operator. * \return "==", "!=", "<", "<=", ">", ">=", "ANY" or "NONE" */ @@ -107,6 +124,10 @@ namespace zypp for_use_in_switch inSwitch() const { return _op; } + /** Enumarator values suitable for libsatsolver. */ + unsigned bits() const + { return _op; } + private: /** Ctor to initialize the relational operator contants. */ Rel( for_use_in_switch op_r )