Imported Upstream version 16.3.2
[platform/upstream/libzypp.git] / zypp / sat / LookupAttr.h
index 5af9688..f547e22 100644 (file)
 #ifndef ZYPP_SAT_LOOKUPATTR_H
 #define ZYPP_SAT_LOOKUPATTR_H
 
-extern "C"
-{
-struct _Dataiterator;
-}
 #include <iosfwd>
 
 #include "zypp/base/PtrTypes.h"
@@ -31,13 +27,12 @@ namespace zypp
   class CheckSum;
   class Match;
   class MatchException;
+  class StrMatcher;
 
   ///////////////////////////////////////////////////////////////////
   namespace sat
   { /////////////////////////////////////////////////////////////////
 
-    class AttrMatcher;
-
     ///////////////////////////////////////////////////////////////////
     //
     // CLASS NAME : LookupAttr
@@ -63,7 +58,9 @@ namespace zypp
      * 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.
+     * 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:
@@ -160,8 +157,9 @@ namespace zypp
         */
         size_type size() const;
 
-        /** TransformIterator returning an \ref iterator vaue of type \c _ResultT. */
-        template<class _ResultT, class _AttrT = _ResultT> class transformIterator;
+        /** TransformIterator returning an \ref iterator vaue of type \c TResult. */
+        template<class TResult, class TAttr = TResult>
+       class TransformIterator;
         //@}
 
       public:
@@ -177,41 +175,41 @@ namespace zypp
         /** \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. */
@@ -284,17 +282,17 @@ namespace zypp
 
     namespace detail
     {
-      /** Wrapper around sat \c ::_Dataiterator.
+      /** Wrapper around sat \c detail::CDataiterator.
        *
        * Manages copy and assign, and release of allocated
        * resources like datamatcher inside the dataiterator.
        * 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 */
+          /** \c NULL \c detail::CDataiterator */
           DIWrap()
           : _dip( 0 )
           {}
@@ -324,20 +322,17 @@ namespace zypp
           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; }
+          detail::CDataiterator * operator->() const  { return _dip; }
+          detail::CDataiterator * 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:
-          ::_Dataiterator * _dip;
+
+       private:
+          detail::CDataiterator * _dip;
           std::string _mstring;
       };
       /** \relates DIWrap Stream output. */
@@ -354,7 +349,7 @@ namespace zypp
      */
     class LookupAttr::iterator : public boost::iterator_adaptor<
         iterator                       // Derived
-        , ::_Dataiterator *            // Base
+        , detail::CDataiterator *            // Base
         , detail::IdType               // Value
         , boost::forward_traversal_tag // CategoryOrTraversal
         , detail::IdType               // Reference
@@ -435,7 +430,7 @@ namespace zypp
          *
          * These are usable iff \ref solvAttrSubEntry is \c true.
          *
-         * \note Unfortunately the underlying satsolver dataiterator as returned
+         * \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
@@ -461,7 +456,7 @@ namespace zypp
          * \endcode
          */
         //@{
-        /** Wheter the sub-structure is empty. */
+        /** Whether the sub-structure is empty. */
         bool subEmpty() const;
 
         /** Ammount of attributes in the sub-structure.
@@ -500,6 +495,8 @@ namespace zypp
         unsigned asUnsigned() const;
         /** \overload */
         bool asBool() const;
+        /** \overload */
+        unsigned long long asUnsignedLL() const;
 
         /** Conversion to string types. */
         const char * c_str() const;
@@ -528,7 +525,7 @@ namespace zypp
          *
          * Should be specialized for supported types above.
         */
-        template<class _Tp> _Tp asType() const { return _Tp(id()); }
+        template<class Tp> Tp asType() const { return Tp(id()); }
         //@}
 
         ///////////////////////////////////////////////////////////////////
@@ -545,7 +542,7 @@ namespace zypp
 
       public:
         /**
-         * C-tor taking over ownership of the passed \c ::_Dataiterator
+         * C-tor taking over ownership of the passed \c detail::CDataiterator
          * and doing it's first iteration (::dataiterator_step)
          */
         iterator( detail::DIWrap & dip_r );
@@ -560,7 +557,7 @@ namespace zypp
               && ( ! base() || dip_equal( *base(), *rhs.base() ) );
         }
 
-        bool dip_equal( const ::_Dataiterator & lhs, const ::_Dataiterator & rhs ) const;
+        bool dip_equal( const detail::CDataiterator & lhs, const detail::CDataiterator & rhs ) const;
 
         detail::IdType dereference() const;
 
@@ -568,7 +565,7 @@ namespace zypp
 
       public:
         /** Expert backdoor. */
-        ::_Dataiterator * get() const
+        detail::CDataiterator * get() const
         { return _dip.get(); }
       private:
         detail::DIWrap _dip;
@@ -584,13 +581,14 @@ namespace zypp
     //@{
     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(); }
     template<> inline IdString     LookupAttr::iterator::asType<IdString>()     const { return idStr(); }
     template<>        CheckSum     LookupAttr::iterator::asType<CheckSum>()     const;
 
-    template<class _ResultT, class _AttrT>
+    template<class TResult, class TAttr>
     class ArrayAttr;
     //@}
 
@@ -602,10 +600,10 @@ namespace zypp
 ///////////////////////////////////////////////////////////////////
 
 /** \relates LookupAttr::iterator Stream output of the underlying iterator for debug. */
-std::ostream & operator<<( std::ostream & str, const ::_Dataiterator * obj );
+std::ostream & operator<<( std::ostream & str, const zypp::sat::detail::CDataiterator * obj );
 
 /** \relates LookupAttr::iterator Stream output of the underlying iterator for debug. */
-inline std::ostream & operator<<( std::ostream & str, const ::_Dataiterator & obj )
+inline std::ostream & operator<<( std::ostream & str, const zypp::sat::detail::CDataiterator & obj )
 { return str << &obj; }
 
 #endif // ZYPP_SAT_LOOKUPATTR_H