ref: refs/heads/master
commit 2716153305817f009f1247d977ef782948a8f19e
Author: Michael Andres
Date: Thu May 28 19:28:01 2009 +0200
Predicate support in PoolQueryMatcher.
---
zypp/PoolQuery.cc | 34 ++++++++++++++++++++++++++++------
zypp/PoolQuery.h | 45 +++++++++++++++++++++++++++++++++++++++------
2 files changed, 67 insertions(+), 12 deletions(-)
diff --git a/zypp/PoolQuery.cc b/zypp/PoolQuery.cc
index b14d578..b0715a6 100644
--- a/zypp/PoolQuery.cc
+++ b/zypp/PoolQuery.cc
@@ -65,7 +65,7 @@ namespace zypp
AttrMatchData( sat::SolvAttr attr_r, const sat::AttrMatcher & attrMatcher_r )
: attr( attr_r )
, attrMatcher( attrMatcher_r )
- { /*predicate = always;*/ }
+ {}
sat::SolvAttr attr;
sat::AttrMatcher attrMatcher;
@@ -1162,10 +1162,18 @@ attremptycheckend:
return false;
}
/////////////////////////////////////////////////////////////////////
- // string matching:
+ // string and predicate matching:
+
if ( _attrMatchList.size() == 1 )
{
- return true; // matching was done by the base iterator
+ // String matching was done by the base iterator.
+ // Now check any predicate:
+ const AttrMatchData::Predicate & predicate( _attrMatchList.front().predicate );
+ if ( ! predicate || predicate( base_r ) )
+ return true;
+
+ base_r.nextSkipSolvable();
+ return false;
}
// Here: search all attributes ;(
@@ -1173,10 +1181,24 @@ attremptycheckend:
{
const AttrMatchData & matchData( *mi );
sat::LookupAttr q( matchData.attr, inSolvable );
- if ( matchData.attrMatcher ) // empty searchstring matches always
+ if ( matchData.attrMatcher ) // an empty searchstring matches always
q.setAttrMatcher( matchData.attrMatcher );
- if ( ! q.empty() )
- return true;
+
+ if ( ! q.empty() ) // there are matches.
+ {
+ // now check any predicate:
+ const AttrMatchData::Predicate & predicate( matchData.predicate );
+ if ( predicate )
+ {
+ for_( it, q.begin(), q.end() )
+ {
+ if ( predicate( it ) )
+ return true;
+ }
+ }
+ else
+ return true;
+ }
}
base_r.nextSkipSolvable();
return false;
diff --git a/zypp/PoolQuery.h b/zypp/PoolQuery.h
index 0bf38ca..b41d775 100644
--- a/zypp/PoolQuery.h
+++ b/zypp/PoolQuery.h
@@ -210,14 +210,47 @@ namespace zypp
* \see sat::SolvAttr
*/
void addAttribute(const sat::SolvAttr & attr, const std::string & value = "");
-
- /*
- * Query for matching dependency attributes.
+#if 0
+ /**
+ * Query for dependencies matching a broken down capability.
*
- * \throws Exception if \a attr is not a dependency attribute
+ * The capabilities \c name part may be defined as ordinary query
+ * string (\see \ref addAttribute), so globing and regex are supported.
+ * \code
+ * addDependency( sat::SolvAttr::provides, "kde*", Edition("2.0"), Rel::GE );
+ * \endcode
+ * \throws Exception in case \a attr is not a dependency attribute.
*/
- //void addDependency( const sat::SolvAttr & attr, Capability cap_r );
- //void addDependency( const sat::SolvAttr & attr, const std::string & name = "");
+ void addDependency( const sat::SolvAttr & attr, const std::string & name,
+ const Edition & edition, const Rel & op = Rel::EQ );
+ /** \overload Query provides */
+ void addProvides( const std::string & name, const Edition & edition, const Rel & op = Rel::EQ )
+ { addDependency( sat::SolvAttr::provides, name, edition, op ); }
+ /** \overload Query requires */
+ void addRequires( const std::string & name, const Edition & edition, const Rel & op = Rel::EQ )
+ { addDependency( sat::SolvAttr::requires, name, edition, op ); }
+ /** \overload Query obsoletes */
+ void addObsoletes( const std::string & name, const Edition & edition, const Rel & op = Rel::EQ )
+ { addDependency( sat::SolvAttr::obsoletes, name, edition, op ); }
+ /** \overload Query conflicts */
+ void addConflicts( const std::string & name, const Edition & edition, const Rel & op = Rel::EQ )
+ { addDependency( sat::SolvAttr::conflicts, name, edition, op ); }
+ /** \overload Query recommends */
+ void addRecommends( const std::string & name, const Edition & edition, const Rel & op = Rel::EQ )
+ { addDependency( sat::SolvAttr::recommends, name, edition, op ); }
+ /** \overload Query suggests */
+ void addSuggests( const std::string & name, const Edition & edition, const Rel & op = Rel::EQ )
+ { addDependency( sat::SolvAttr::suggests, name, edition, op ); }
+ /** \overload Query supplements */
+ void addSupplements( const std::string & name, const Edition & edition, const Rel & op = Rel::EQ )
+ { addDependency( sat::SolvAttr::supplements, name, edition, op ); }
+ /** \overload Query enhances */
+ void addEnhances( const std::string & name, const Edition & edition, const Rel & op = Rel::EQ )
+ { addDependency( sat::SolvAttr::enhances, name, edition, op ); }
+
+ /** \overload Query taking a \ref Capability (always exact name match) */
+ void addDependency( const sat::SolvAttr & attr, Capability cap_r );
+#endif
/**
* Set version condition. This will filter out solvables not matching
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org