Add Capability::guessPackageSpec allowing to detect whether the argument was rewritten.
authorMichael Andres <ma@suse.de>
Fri, 26 Mar 2010 13:12:19 +0000 (14:12 +0100)
committerMichael Andres <ma@suse.de>
Fri, 26 Mar 2010 18:30:24 +0000 (19:30 +0100)
zypp/Capability.cc
zypp/Capability.h

index dd4c3c6..96230be 100644 (file)
@@ -365,7 +365,7 @@ namespace zypp
     return str::regex_match( name_r, what, filenameRegex );
   }
 
-  Capability Capability::guessPackageSpec( const std::string & str_r )
+  Capability Capability::guessPackageSpec( const std::string & str_r, bool & rewrote_r )
   {
     Capability cap( str_r );
     CapDetail detail( cap.detail() );
@@ -386,7 +386,10 @@ namespace zypp
       ResPool pool( ResPool::instance() );
       // require name part matching a pool items name (not just provides!)
       if ( pool.byIdentBegin( detail.name() ) != pool.byIdentEnd( detail.name() ) )
+      {
+       rewrote_r = true;
        return guesscap;
+      }
 
       // try the one but last '-'
       if ( pos )
@@ -401,13 +404,24 @@ namespace zypp
 
           // require name part matching a pool items name (not just provides!)
           if ( pool.byIdentBegin( detail.name() ) != pool.byIdentEnd( detail.name() ) )
+         {
+           rewrote_r = true;
            return guesscap;
+         }
         }
       }
     }
+
+    rewrote_r = false;
     return cap;
   }
 
+  Capability guessPackageSpec( const std::string & str_r )
+  {
+    bool dummy;
+    return guessPackageSpec( str_r, dummy );
+  }
+
   /******************************************************************
   **
   **   FUNCTION NAME : operator<<
index 06758d2..8f76c2c 100644 (file)
@@ -236,6 +236,11 @@ namespace zypp
        * result depends on the pools content.
        */
       static Capability guessPackageSpec( const std::string & str_r );
+      /** \overload Taking an additional bool indicating whether \c str_r made
+       * a valid \ref Capability (\c true) or the result was was guessed by
+       * rewiting a \c '-' to \c '='. (\c false).
+       */
+      static Capability guessPackageSpec( const std::string & str_r, bool & rewrote_r );
 
     public:
       /** Expert backdoor. */