class CheckSum;
class Match;
class MatchException;
+ class StrMatcher;
///////////////////////////////////////////////////////////////////
namespace sat
{ /////////////////////////////////////////////////////////////////
- class AttrMatcher;
-
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : LookupAttr
*
* Use \ref SolvAttr::allAttr to search all attributes.
*
+ * To search for attributes located in a sub-structure (flexarray)
+ * you also have to pass the sub-structures attribute as parent.
+ * Passing \ref SolvAttr::allAttr a parent will lookup the attribute
+ * in \c any sub-structure. Few attributes are known to have a parent
+ * (\see \ref SolvAttr::parent). Setting those attributes will automatically
+ * initialize their parent value.
+ *
+ * \code
+ * // Lookup all 'name' attributes:
+ * sat::LookupAttr q( sat::SolvAttr::name );
+ * // Lookup all 'name' attributes within a sub-structure 'data':
+ * sat::LookupAttr q( sat::SolvAttr::name, sat::SolvAttr::data );
+ * // Lookup all 'name' attributes within any sub-structure:
+ * sat::LookupAttr q( sat::SolvAttr::name, sat::SolvAttr::allAttr );
+ * \endcode
+ *
* \code
* // look for all attributes of one solvable
* void ditest( sat::Solvable slv_r )
/** Lookup \ref SolvAttr in \ref Pool (all repositories). */
explicit LookupAttr( SolvAttr attr_r, Location = SOLV_ATTR );
+ /** \overload SolvAttr within sub-structure \a parent_r. */
+ LookupAttr( SolvAttr attr_r, SolvAttr parent_r, Location = SOLV_ATTR );
/** Lookup \ref SolvAttr in one\ref Repository. */
- explicit LookupAttr( SolvAttr attr_r, Repository repo_r, Location = SOLV_ATTR );
+ LookupAttr( SolvAttr attr_r, Repository repo_r, Location = SOLV_ATTR );
+ /** \overload SolvAttr within sub-structure \a parent_r. */
+ LookupAttr( SolvAttr attr_r, SolvAttr parent_r, Repository repo_r, Location = SOLV_ATTR );
/** Lookup \ref SolvAttr in one \ref Solvable. */
LookupAttr( SolvAttr attr_r, Solvable solv_r );
+ /** \overload SolvAttr within sub-structure \a parent_r. */
+ LookupAttr( SolvAttr attr_r, SolvAttr parent_r, Solvable solv_r );
public:
/** \name Search result. */
/** \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:
+ * You can also evaluate \ref StrMatcher in a boolean context,
+ * in order to test whether an \ref StrMatcher is set:
* \code
* LookupAttr q;
- * if ( q.attrMatcher() )
- * ...; // an AttrMatcher is set
+ * if ( q.strMatcher() )
+ * ...; // an StrMatcher is set
* \endcode
*/
- const AttrMatcher & attrMatcher() const;
+ const StrMatcher & strMatcher() const;
/** Set the pattern to match.
- * \throws MatchException Any of the exceptions thrown by \ref AttrMatcher::compile.
+ * \throws MatchException Any of the exceptions thrown by \ref StrMatcher::compile.
*/
- void setAttrMatcher( const AttrMatcher & matcher_r );
+ void setStrMatcher( const StrMatcher & matcher_r );
/** Reset the pattern to match. */
- void resetAttrMatcher();
+ void resetStrMatcher();
//@}
public:
/** \name Where to search. */
//@{
- /** Wheter to search in \ref Pool. */
+ /** Whether to search in \ref Pool. */
bool pool() const;
/** Set search in \ref Pool (all repositories). */
void setPool( Location = SOLV_ATTR );
- /** Wheter to search in one \ref Repository. */
+ /** Whether to search in one \ref Repository. */
Repository repo() const;
/** Set search in one \ref Repository. */
void setRepo( Repository repo_r, Location = SOLV_ATTR );
- /** Wheter to search in one \ref Solvable. */
+ /** Whether to search in one \ref Solvable. */
Solvable solvable() const;
/** Set search in one \ref Solvable. */
void setSolvable( Solvable solv_r );
+
+ /** Whether to search within a sub-structure (\ref SolvAttr::noAttr if not) */
+ SolvAttr parent() const;
+
+ /** Set search within a sub-structure (\ref SolvAttr::noAttr for none) */
+ void setParent( SolvAttr attr_r );
//@}
private:
//
// CLASS NAME : LookupRepoAttr
//
- /** Lightweight repositor attribute value lookup.
+ /** Lightweight repository attribute value lookup.
*
* This is just a convenience class that overloads all
* \ref LookupAttr methods which take a \ref LookupAttr::Location
* Also maintains a copy of the matchstring in order to
* keep the char* passed to the dataiterator valid.
*/
- class DIWrap : private base::SafeBool<DIWrap>
+ class DIWrap
{
public:
/** \c NULL \c ::_Dataiterator */
void reset()
{ DIWrap().swap( *this ); }
public:
-#ifndef SWIG // Swig treats it as syntax error
/** Evaluate in a boolean context <tt>( _dip != NULL )</tt>. */
- using base::SafeBool<DIWrap>::operator bool_type;
-#endif
+ explicit operator bool() const
+ { return _dip; }
+
public:
::_Dataiterator * operator->() const { return _dip; }
::_Dataiterator * get() const { return _dip; }
const std::string & getstr() const { return _mstring; }
- private:
- friend base::SafeBool<DIWrap>::operator bool_type() const;
- bool boolTest() const
- { return _dip; }
- private:
+
+ private:
::_Dataiterator * _dip;
std::string _mstring;
};
/** Immediately advance to the next \ref Repository. */
void skipRepo()
{ nextSkipRepo(); increment(); }
+
+ /** Stop after all matches in the current \ref Solvable are processed. */
+ void stayInThisSolvable();
+
+ /** Stop after all matches in the current \ref Repository are processed. */
+ void stayInThisRepo();
//@}
/** \name Current position info. */
/** The current \ref SolvAttr. */
SolvAttr inSolvAttr() const;
+
+ /** Whether this points to the end of a query (Iterator is invalid). */
+ bool atEnd() const
+ { return !_dip; }
//@}
/** \name Test attribute value type. */
*
* These are usable iff \ref solvAttrSubEntry is \c true.
*
+ * \note Unfortunately the underlying libsolv dataiterator as returned
+ * by \ref subBegin and \ref subFind loses some context when being created.
+ * Thus it's not possible to invoke \ref subBegin and \ref subFind on an
+ * iterator that was previously returned by one of those methods. The result
+ * will be an \c end iterator. For the same reason it is not possible for an
+ * iterator to leave the sub-structure again.
+ *
* \code
* // Lookup all "update:reference" entries for a specific solvable
* sat::LookupAttr q( sat::SolvAttr::updateReference, p->satSolvable() );
* \endcode
*/
//@{
- /** Wheter the sub-structure is empty. */
+ /** Whether the sub-structure is empty. */
bool subEmpty() const;
/** Ammount of attributes in the sub-structure.
unsigned asUnsigned() const;
/** \overload */
bool asBool() const;
+ /** \overload */
+ unsigned long long asUnsignedLL() const;
/** Conversion to string types. */
const char * c_str() const;
//@{
template<> inline int LookupAttr::iterator::asType<int>() const { return asInt(); }
template<> inline unsigned LookupAttr::iterator::asType<unsigned>() const { return asUnsigned(); }
+ template<> inline unsigned long long LookupAttr::iterator::asType<unsigned long long>() const { return asUnsignedLL(); }
template<> inline bool LookupAttr::iterator::asType<bool>() const { return asBool(); }
template<> inline const char * LookupAttr::iterator::asType<const char *>() const { return c_str(); }
template<> inline std::string LookupAttr::iterator::asType<std::string>() const { return asString(); }