ref: refs/heads/ma-tmp-pqt
commit 5c050767ffd8b24dc827d6b0fd2fe5ca32a1f6d5
Author: Michael Andres
Date: Thu Apr 9 16:14:24 2009 +0200
Allow to define AttrMatcher in LookupAttr.
---
zypp/sat/LookupAttr.cc | 31 +++++++++++++++++++++++++++----
zypp/sat/LookupAttr.h | 22 ++++++++++++++++++++++
2 files changed, 49 insertions(+), 4 deletions(-)
diff --git a/zypp/sat/LookupAttr.cc b/zypp/sat/LookupAttr.cc
index 1b43889..1bb4d54 100644
--- a/zypp/sat/LookupAttr.cc
+++ b/zypp/sat/LookupAttr.cc
@@ -17,9 +17,11 @@
#include "zypp/sat/detail/PoolImpl.h"
+#include "zypp/sat/Pool.h"
#include "zypp/sat/LookupAttr.h"
+#include "zypp/sat/AttrMatcher.h"
+
#include "zypp/CheckSum.h"
-#include "zypp/sat/Pool.h"
using std::endl;
@@ -72,6 +74,12 @@ namespace zypp
void setAttr( SolvAttr attr_r )
{ _attr = attr_r; }
+ const AttrMatcher & attrMatcher() const
+ { return _attrMatcher; }
+
+ void setAttrMatcher( const AttrMatcher & matcher_r )
+ { _attrMatcher = matcher_r; }
+
public:
bool pool() const
{ return ! (_repo || _solv); }
@@ -110,17 +118,25 @@ namespace zypp
// needed while LookupAttr::iterator::dip_equal does ::memcmp:
::memset( dip.get(), 0, sizeof(::_Dataiterator) );
+ const char * m = 0;
+ int f = 0;
+ if ( _attrMatcher )
+ {
+ m = _attrMatcher.searchstring().c_str();
+ f = _attrMatcher.flags();
+ }
+
if ( _solv )
{
- ::dataiterator_init( dip.get(), sat::Pool::instance().get(), _solv.repository().id(), _solv.id(), _attr.id(), 0, 0 );
+ ::dataiterator_init( dip.get(), sat::Pool::instance().get(), _solv.repository().id(), _solv.id(), _attr.id(), m, f );
}
else if ( _repo )
{
- ::dataiterator_init( dip.get(), sat::Pool::instance().get(), _repo.id(), _solv.id(), _attr.id(), 0, 0 );
+ ::dataiterator_init( dip.get(), sat::Pool::instance().get(), _repo.id(), _solv.id(), _attr.id(), m, f );
}
else if ( ! sat::Pool::instance().reposEmpty() )
{
- ::dataiterator_init( dip.get(), sat::Pool::instance().get(), 0, _solv.id(), _attr.id(), 0, 0 );
+ ::dataiterator_init( dip.get(), sat::Pool::instance().get(), 0, _solv.id(), _attr.id(), m, f );
}
else
return end();
@@ -135,6 +151,7 @@ namespace zypp
SolvAttr _attr;
Repository _repo;
Solvable _solv;
+ AttrMatcher _attrMatcher;
private:
friend Impl * rwcowClone<Impl>( const Impl * rhs );
@@ -173,6 +190,12 @@ namespace zypp
void LookupAttr::setAttr( SolvAttr attr_r )
{ _pimpl->setAttr( attr_r ); }
+ const AttrMatcher & LookupAttr::attrMatcher() const
+ { return _pimpl->attrMatcher(); }
+
+ void LookupAttr::setAttrMatcher( const AttrMatcher & matcher_r )
+ { _pimpl->setAttrMatcher( matcher_r ); }
+
///////////////////////////////////////////////////////////////////
bool LookupAttr::pool() const
diff --git a/zypp/sat/LookupAttr.h b/zypp/sat/LookupAttr.h
index 1d052e8..a412d8f 100644
--- a/zypp/sat/LookupAttr.h
+++ b/zypp/sat/LookupAttr.h
@@ -34,6 +34,8 @@ namespace zypp
namespace sat
{ /////////////////////////////////////////////////////////////////
+ class AttrMatcher;
+
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : LookupAttr
@@ -147,6 +149,26 @@ namespace zypp
void setAttr( SolvAttr attr_r );
//@}
+ /** \name Restrict attributes to match a pattern. */
+ //@{
+ /** The pattern to match.
+ * You can also evaluate \ref AttrMatcher in a boolean context,
+ * in order to test whether an \ref AttrMatcher is set:
+ * \code
+ * LookupAttr q;
+ * if ( q.attrMatcher() )
+ * ...; // an AttrMatcher is set
+ * \endcode
+ */
+ const AttrMatcher & attrMatcher() const;
+
+ /** Set the pattern to match. */
+ void setAttrMatcher( const AttrMatcher & matcher_r );
+
+ /** Reset the pattern to match. */
+ void resetAttrMatcher();
+ //@}
+
public:
/** \name Where to search. */
//@{
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org