From: Michael Andres Date: Wed, 2 Sep 2009 13:46:47 +0000 (+0200) Subject: Add AttrMatcher == != and < (for std::container) X-Git-Tag: 6.14.0~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=558cf1b3c276d4e9a35fba80ea711990ba83964f;p=platform%2Fupstream%2Flibzypp.git Add AttrMatcher == != and < (for std::container) --- diff --git a/zypp/sat/AttrMatcher.cc b/zypp/sat/AttrMatcher.cc index 6001110..1a522a7 100644 --- a/zypp/sat/AttrMatcher.cc +++ b/zypp/sat/AttrMatcher.cc @@ -275,6 +275,10 @@ namespace zypp : _pimpl( new Impl( search_r, flags_r ) ) {} + AttrMatcher::AttrMatcher( const std::string & search_r, const Match::Mode & flags_r ) + : _pimpl( new Impl( search_r, flags_r ) ) + {} + AttrMatcher::AttrMatcher( const std::string & search_r, int flags_r ) : _pimpl( new Impl( search_r, Match(flags_r) ) ) {} @@ -316,6 +320,20 @@ namespace zypp return str << *obj._pimpl; } + bool operator==( const AttrMatcher & lhs, const AttrMatcher & rhs ) + { + return ( lhs.flags() == rhs.flags() + && lhs.searchstring() == rhs.searchstring() ); + } + + bool operator<( const AttrMatcher & lhs, const AttrMatcher & rhs ) + { + if ( lhs.flags().get() != rhs.flags().get() ) + return ( lhs.flags().get() < rhs.flags().get() ); + + return ( lhs.searchstring() < rhs.searchstring() ); + } + ///////////////////////////////////////////////////////////////// } // namespace sat /////////////////////////////////////////////////////////////////// diff --git a/zypp/sat/AttrMatcher.h b/zypp/sat/AttrMatcher.h index 39dbc2d..e557b07 100644 --- a/zypp/sat/AttrMatcher.h +++ b/zypp/sat/AttrMatcher.h @@ -330,6 +330,12 @@ namespace zypp /** Ctor taking string and \ref Match flags. */ AttrMatcher( const std::string & search_r, const Match & flags_r ); + /** Ctor taking string and \ref Match::Mode. + * Needed because we want them to be treated as \ref Match, + * and not as \ref int as the compiler woud do. + */ + AttrMatcher( const std::string & search_r, const Match::Mode & flags_r ); + /** Low level interface wraps \a flags into \ref Match. */ AttrMatcher( const std::string & search_r, int flags_r ); @@ -399,6 +405,16 @@ namespace zypp /** \relates AttrMatcher Stream output */ std::ostream & operator<<( std::ostream & str, const AttrMatcher & obj ); + /** \relates AttrMatcher */ + bool operator==( const AttrMatcher & lhs, const AttrMatcher & rhs ); + + /** \relates AttrMatcher */ + inline bool operator!=( const AttrMatcher & lhs, const AttrMatcher & rhs ) + { return !( lhs == rhs ); } + + /** \relates AttrMatcher Arbitrary order for std::container. */ + bool operator<( const AttrMatcher & lhs, const AttrMatcher & rhs ); + ///////////////////////////////////////////////////////////////// } // namespace sat ///////////////////////////////////////////////////////////////////