ref: refs/heads/master
commit 9d07a5f6efcf13d64f1f7278ca76928de32ab10a
Author: Michael Andres
Date: Wed Oct 14 16:22:43 2009 +0200
Add Solvable::providesNamespace/valuesOfNamespace: evaluation of namespace provides
---
zypp/Resolvable.h | 6 ++++++
zypp/sat/Solvable.cc | 33 +++++++++++++++++++++++++++++++++
zypp/sat/Solvable.h | 12 ++++++++++++
3 files changed, 51 insertions(+), 0 deletions(-)
diff --git a/zypp/Resolvable.h b/zypp/Resolvable.h
index c697b8e..40c9a92 100644
--- a/zypp/Resolvable.h
+++ b/zypp/Resolvable.h
@@ -121,6 +121,12 @@ namespace zypp
Capabilities prerequires() const
{ return sat::Solvable::prerequires(); }
+
+ CapabilitySet providesNamespace( const std::string & namespace_r ) const
+ { return sat::Solvable::providesNamespace( namespace_r ); }
+
+ CapabilitySet valuesOfNamespace( const std::string & namespace_r ) const
+ { return sat::Solvable::valuesOfNamespace( namespace_r ); }
//@}
public:
diff --git a/zypp/sat/Solvable.cc b/zypp/sat/Solvable.cc
index 64f6a97..c7bdaf9 100644
--- a/zypp/sat/Solvable.cc
+++ b/zypp/sat/Solvable.cc
@@ -441,6 +441,39 @@ namespace zypp
: Capabilities();
}
+ CapabilitySet Solvable::providesNamespace( const std::string & namespace_r ) const
+ {
+ NO_SOLVABLE_RETURN( CapabilitySet() );
+ CapabilitySet ret;
+ Capabilities caps( provides() );
+ for_( it, caps.begin(), caps.end() )
+ {
+ CapDetail caprep( it->detail() );
+ if ( str::hasPrefix( caprep.name().c_str(), namespace_r ) && *(caprep.name().c_str()+namespace_r.size()) == '(' )
+ ret.insert( *it );
+ }
+ return ret;
+ }
+
+ CapabilitySet Solvable::valuesOfNamespace( const std::string & namespace_r ) const
+ {
+ NO_SOLVABLE_RETURN( CapabilitySet() );
+ CapabilitySet ret;
+ Capabilities caps( provides() );
+ for_( it, caps.begin(), caps.end() )
+ {
+ CapDetail caprep( it->detail() );
+ if ( str::hasPrefix( caprep.name().c_str(), namespace_r ) && *(caprep.name().c_str()+namespace_r.size()) == '(' )
+ {
+ std::string value( caprep.name().c_str()+namespace_r.size()+1 );
+ value[value.size()-1] = '\0'; // erase the trailing ')'
+ ret.insert( Capability( value, caprep.op(), caprep.ed() ) );
+ }
+ }
+ return ret;
+ }
+
+
std::string Solvable::asString() const
{
NO_SOLVABLE_RETURN( (_id == detail::systemSolvableId ? "systemSolvable" : "noSolvable") );
diff --git a/zypp/sat/Solvable.h b/zypp/sat/Solvable.h
index a880630..4a3dda9 100644
--- a/zypp/sat/Solvable.h
+++ b/zypp/sat/Solvable.h
@@ -198,6 +198,18 @@ namespace zypp
Capabilities enhances() const;
Capabilities supplements() const;
Capabilities prerequires() const;
+
+ /** Return the namespaced provides <tt>'namespace([value])[ op edition]'</tt> of this Solvable. */
+ CapabilitySet providesNamespace( const std::string & namespace_r ) const;
+
+ /** Return <tt>'value[ op edition]'</tt> for namespaced provides <tt>'namespace(value)[ op edition]'</tt>.
+ * Similar to \ref providesNamespace, but the namespace is stripped from the
+ * dependencies. This is convenient if the namespace denotes packages that
+ * should be looked up. E.g. the \c weakremover namespace used in a products
+ * release package denotes the packages that were dropped from the distribution.
+ * \see \ref Product::droplist
+ */
+ CapabilitySet valuesOfNamespace( const std::string & namespace_r ) const;
//@}
public:
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org