ref: refs/heads/ma-misc
commit 558cf1b3c276d4e9a35fba80ea711990ba83964f
Author: Michael Andres
Date: Wed Sep 2 15:46:47 2009 +0200
Add AttrMatcher == != and < (for std::container)
---
zypp/sat/AttrMatcher.cc | 18 ++++++++++++++++++
zypp/sat/AttrMatcher.h | 16 ++++++++++++++++
2 files changed, 34 insertions(+), 0 deletions(-)
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
///////////////////////////////////////////////////////////////////
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org