id based Edition
authorMichael Andres <ma@suse.de>
Mon, 14 Jan 2008 12:38:16 +0000 (12:38 +0000)
committerMichael Andres <ma@suse.de>
Mon, 14 Jan 2008 12:38:16 +0000 (12:38 +0000)
13 files changed:
zypp/Edition.cc
zypp/Edition.h
zypp/ResKind.h
zypp/parser/susetags/ContentFileReader.cc
zypp/parser/yum/ProductFileReader.cc
zypp/repo/cached/PackageImpl.cc
zypp/repo/cached/ProductImpl.cc
zypp/sat/IdStrType.h
zypp/sat/Pool.cc
zypp/sat/Solvable.cc
zypp/sat/Solvable.h
zypp/sat/detail/PoolMember.h
zypp/target/store/XMLFilesBackend.cc

index 35072fd..ba877b9 100644 (file)
@@ -9,14 +9,14 @@
 /** \file zypp/Edition.cc
  *
 */
-#include <iostream>
-
-#include "zypp/base/Logger.h"
-#include "base/String.h"
-#include "base/Regex.h"
-#include "base/Exception.h"
+extern "C"
+{
+#include <satsolver/evr.h>
+}
+#include "zypp/base/String.h"
 
 #include "zypp/Edition.h"
+#include "zypp/sat/Pool.h"
 
 using namespace std;
 
@@ -25,297 +25,91 @@ namespace zypp
 { /////////////////////////////////////////////////////////////////
 
   ///////////////////////////////////////////////////////////////////
-  //
-  //   hidden details
-  //
-  ///////////////////////////////////////////////////////////////////
   namespace
-  {
-    /** Rpm version comparison.
-     * \a lhs and \a rhs are expected to be either version or release
-     * strings. Not both separated by a '-'.
-     * \return <tt>-1,0,1</tt> if version strings are <tt>\<,==,\></tt>
-     * \todo review
-    */
-    int rpmverscmp( const std::string & lhs, const std::string & rhs )
-    {
-      int  num1, num2;
-      char oldch1, oldch2;
-      char * str1, * str2;
-      char * one, * two;
-      int  rc;
-      int  isnum;
-
-      // equal?
-      if ( lhs == rhs )  return 0;
-
-      // empty is less than anything else:
-      if ( lhs.empty() ) return -1;
-      if ( rhs.empty() ) return  1;
-
-      str1 = (char*)alloca( lhs.size() + 1 );
-      str2 = (char*)alloca( rhs.size() + 1 );
-
-      strcpy( str1, lhs.c_str() );
-      strcpy( str2, rhs.c_str() );
-
-      one = str1;
-      two = str2;
-
-      // split strings into segments of alpha or digit
-      // sequences and compare them accordingly.
-      while ( *one && *two ) {
+  { /////////////////////////////////////////////////////////////////
 
-        // skip non alphanumerical chars
-        while ( *one && ! isalnum( *one ) ) ++one;
-        while ( *two && ! isalnum( *two ) ) ++two;
-        if ( ! ( *one && *two ) )
-          break; // reached end of string
-
-        // remember segment start
-        str1 = one;
-        str2 = two;
-
-        // jump over segment, type determined by str1
-        if ( isdigit( *str1 ) ) {
-          while ( isdigit( *str1 ) ) ++str1;
-          while ( isdigit( *str2 ) ) ++str2;
-          isnum = 1;
-        } else {
-          while ( isalpha( *str1 ) ) ++str1;
-          while ( isalpha( *str2 ) ) ++str2;
-          isnum = 0;
-        }
-
-        // one == str1 -> can't be as strings are not empty
-        // two == str2 -> mixed segment types
-        if ( two == str2 ) return( isnum ? 1 : -1 );
-
-        // compare according to segment type
-        if ( isnum ) {
-          // atoi() may overflow on long segments
-          // skip leading zeros
-          while ( *one == '0' ) ++one;
-          while ( *two == '0' ) ++two;
-          // compare number of digits
-          num1 = str1 - one;
-          num2 = str2 - two;
-          if ( num1 != num2 ) return( num1 < num2 ? -1 : 1 );
-        }
-
-        // strcmp() compares alpha AND equal sized number segments
-        // temp. \0-terminate segment
-        oldch1 = *str1;
-        *str1 = '\0';
-        oldch2 = *str2;
-        *str2 = '\0';
-
-        rc = strcmp( one, two );
-        if ( rc ) return rc;
-
-        // restore original strings
-        *str1 = oldch1;
-        *str2 = oldch2;
-
-        // prepare for next cycle
-        one = str1;
-        two = str2;
-      }
-
-      // check which strings are now empty
-      if ( !*one ) {
-        return( !*two ? 0 : -1 );
-      }
-      return 1;
-    }
-  } // namespace
-  ///////////////////////////////////////////////////////////////////
-
-  ///////////////////////////////////////////////////////////////////
-  //
-  //   CLASS NAME : Edition::Impl
-  //
-  /** Edition implementation.
-   * \todo Unifiy Impl in Edition::noedition and Edition::Edition()
-  */
-  struct Edition::Impl
-  {
-    Impl()
-    : _epoch( noepoch )
-    {}
-
-    Impl( const std::string & edition_r )
-    : _epoch( noepoch )
+    inline std::string makeevrstr( const std::string & version_r,
+                                   const std::string & release_r,
+                                   Edition::epoch_t epoch_r )
     {
-      //[0-9]+:)?([^-]*)(-([^-]*))?" );
-      str::smatch what;
-
-      if( str::regex_match( edition_r, what, _rxEdition )
-          && what[3].size() != 1)
-        {
-          if ( what[1].size() > 1 )
-            _epoch = strtoul( what[1].c_str(), NULL, 10 );
-          if ( what[2].size() )
-            _version = what[2];
-          if (what[3].size() )
-            _release = what[3].substr(1);
-        }
-      else
-        {
-          ZYPP_THROW( Exception(string("Invalid Edition: ")+edition_r) );
-        }
-    }
-
-    Impl( const std::string & version_r,
-          const std::string & release_r,
-          epoch_t epoch_r )
-    : _epoch( epoch_r )
-    , _version( validateVR(version_r) )
-    , _release( validateVR(release_r) )
-    {}
-
-    Impl( const std::string & version_r,
-          const std::string & release_r,
-          const std::string & epoch_r )
-    : _epoch( validateE(epoch_r) )
-    , _version( validateVR(version_r) )
-    , _release( validateVR(release_r) )
-    {}
-
-    /** Dtor */
-    ~Impl()
-    {}
-
-    /** return validated epoch ([0-9]*) or throw */
-    static epoch_t validateE( const std::string & epoch_r )
-    {
-      if ( epoch_r.empty() )
-        return noepoch;
-
-      char * endptr = NULL;
-      epoch_t ret = strtoul( epoch_r.c_str(), &endptr, 10 );
-      if ( *endptr != '\0' )
-        ZYPP_THROW( Exception(string("Invalid eopch: ")+epoch_r) );
-      return ret;
-    }
-
-    /** return validated version/release or throw */
-    static const std::string & validateVR( const std::string & vr_r )
-    {
-      if ( vr_r.find('-') != string::npos )
-        ZYPP_THROW( Exception(string("Invalid version/release: ")+vr_r) );
-    
-      return vr_r;
+      std::string ret( version_r );
+      if ( ! release_r.empty() )
+      {
+        ret += "-";
+        ret += release_r;
+      }
+      return ( epoch_r ? str::numstring( epoch_r ) + ":" + ret
+                       : ret );
     }
 
-    epoch_t      _epoch;
-    std::string _version;
-    std::string _release;
-
-    static const str::regex _rxEdition;
-  };
-  ///////////////////////////////////////////////////////////////////
-
-  const str::regex Edition::Impl::_rxEdition( "([0-9]+:)?([^-]*)(-[^-]*)?" );
-
-  ///////////////////////////////////////////////////////////////////
-
-  ///////////////////////////////////////////////////////////////////
-  //
-  //   CLASS NAME : Edition
-  //
+    /////////////////////////////////////////////////////////////////
+  } // namespace
   ///////////////////////////////////////////////////////////////////
 
   const Edition Edition::noedition;
 
   ///////////////////////////////////////////////////////////////////
 
-  Edition::Edition()
-  : _pimpl( new Impl )
-  {}
-
-  Edition::Edition( const std::string & edition_r )
-  : _pimpl( new Impl( edition_r ) )
-  {}
-
   Edition::Edition( const std::string & version_r,
                     const std::string & release_r,
                     epoch_t epoch_r )
-  : _pimpl( new Impl( version_r, release_r, epoch_r ) )
+  : _str( makeevrstr( version_r, release_r, epoch_r ) )
   {}
 
   Edition::Edition( const std::string & version_r,
                     const std::string & release_r,
                     const std::string & epoch_r )
-  : _pimpl( new Impl( version_r, release_r, epoch_r ) )
-  {}
-
-  Edition::~Edition()
+  : _str( makeevrstr( version_r, release_r, str::strtonum<epoch_t>( epoch_r ) ) )
   {}
 
   Edition::epoch_t Edition::epoch() const
-  { return _pimpl->_epoch; }
+  {
+    const char * str( c_str() );
+    const char * sep = str;
+    // skip edition
+    for ( ; *sep >= '0' && *sep <= '9'; ++sep )
+      ; // NOOP
+    if ( *sep == ':' )
+      return str::strtonum<epoch_t>( std::string( str, sep-str ) );
+    return 0;
+  }
 
   const std::string & Edition::version() const
-  { return _pimpl->_version; }
+  {
+    const char * str( c_str() );
+    const char * sep = str;
+    // skip edition
+    for ( ; *sep >= '0' && *sep <= '9'; ++sep )
+      ; // NOOP
+    if ( *sep == ':' )
+      str = sep+1;
+    // strip release
+    sep = ::strrchr( str, '-' );
+    if ( sep )
+      return std::string( str, sep-str );
+    return str;
+  }
 
   const std::string & Edition::release() const
-  { return _pimpl->_release; }
-
-  std::string Edition::asString() const
   {
-    string ret;
-
-    if ( _pimpl->_epoch )
-      ret += str::form(  "%d:", _pimpl->_epoch );
-
-    ret += _pimpl->_version;
-
-    if ( ! _pimpl->_release.empty() )
-      {
-        ret += '-';
-        ret += _pimpl->_release;
-      }
-
-    if ( ret.empty() )
-      return "";
-
-    return ret;
+    const char * str( c_str() );
+    const char * sep = ::strrchr( str, '-' );
+    // get release
+    if ( sep )
+      return sep+1;
+    return std::string();
   }
 
-  int Edition::compare( const Edition & lhs, const Edition & rhs )
+  int Edition::_doCompareC( const char * rhs ) const
   {
-    // compare epoch
-    if ( lhs.epoch() != rhs.epoch() )
-      return lhs.epoch() < rhs.epoch() ? -1 : 1;
-
-    // next compare versions
-    int res = rpmverscmp( lhs.version(), rhs.version() );
-    if ( res )
-      return res; // -1|1: not equal
-
-    return rpmverscmp( lhs.release(), rhs.release() );
+    return ::evrcmp_str( sat::Pool::instance().get(),
+                         c_str(), rhs, EVRCMP_COMPARE );
   }
 
-  int Edition::match( const Edition & lhs, const Edition & rhs )
+  int Edition::_doMatchC( const char * rhs )  const
   {
-    // compare epoch
-    if ( lhs.epoch() != rhs.epoch() )
-      return lhs.epoch() < rhs.epoch() ? -1 : 1;
-
-    // next compare versions
-    if ( lhs.version().empty() || rhs.version().empty() )
-      return 0; //equal
-
-    int res = rpmverscmp( lhs.version(), rhs.version() );
-    if ( res )
-      return res; // -1|1: not equal
-
-    // finaly compare releases
-    if ( lhs.release().empty() || rhs.release().empty() )
-      return 0; //equal
-
-    return rpmverscmp( lhs.release(), rhs.release() );
+    return ::evrcmp_str( sat::Pool::instance().get(),
+                         c_str(), rhs, EVRCMP_MATCH );
   }
 
   /////////////////////////////////////////////////////////////////
index a514f53..e194cc9 100644 (file)
 #define ZYPP_EDITION_H
 
 #include <iosfwd>
-#include <functional>
 #include <string>
+#include <functional>
 
-#include "zypp/base/PtrTypes.h"
-
+#include "zypp/sat/IdStrType.h"
 #include "zypp/RelCompare.h"
 #include "zypp/Range.h"
 
@@ -51,183 +50,124 @@ namespace zypp
    * \attention operator< defines equivalence classes of version strings, as non
    * alphanumeric chars are ignored. That' why \c 1.0 and \c 1_0 compare equal
    * in the example.<BR>
-   * If Edition is used as key in a std::container, per default
-   * <em>plain string comparison</em> is used. If you want to compare by
-   * version, let the container use \ref CompareByLT<Edition> to compare.
    *
    * \attention Edition::match compares two editions, treating empty
    * version or release strings as wildcard. Thus match is not transitive,
    * and you don't want to use it to order keys in a a std::container.
    *
    * \ingroup g_BackendSpecific
-   * \todo Define exceptions.
-   * \todo optimize implementation(e.g don't store epoch if noepoch)
-   * \todo implement debian comparison and make choice backend specific
-   * \todo optimize noedition. unified Impl and quick check in compare.
   */
-  class Edition
+  class Edition : public sat::IdStrType<Edition>
   {
-  public:
-    /** Type of an epoch. */
-    typedef unsigned epoch_t;
+    public:
+      /** Type of an epoch. */
+      typedef unsigned epoch_t;
 
-    /** Value representing \c noepoch. */
-    static const epoch_t noepoch = 0;
+      /** Value representing \c noepoch. */
+      static const epoch_t noepoch = 0;
 
-    /** Value representing \c noedition.
+    /** Value representing \c noedition (<tt>""</tt>)
      * This is in fact a valid Edition. It's what the default ctor
      * creates or will be parsed from an empty string.
-    */
-    static const Edition noedition;
-
-  public:
-    /** Default ctor: \ref noedition. */
-    Edition();
-
-    /** Ctor taking edition as string.
-     * \throw INTERNAL if \a edition_r does not make a valid Edition.
-    */
-    Edition( const std::string & edition_r );
-
-    /** Ctor taking \a version_r, \a release_r and optional \a epoch_r
-     * \throw INTERNAL if \a version_r or \a release_r are not valid.
-    */
-    Edition( const std::string & version_r,
-             const std::string & release_r,
-             epoch_t epoch_r = noepoch );
-
-    /** Ctor taking \a version_r, \a release_r and optional \a epoch_r as string.
-     * \throw INTERNAL if \a version_r or \a release_r \a epoch_r are
-     * not valid.
-    */
-    Edition( const std::string & version_r,
-             const std::string & release_r,
-             const std::string & epoch_r );
-
-    /** Dtor */
-    ~Edition();
-
-  public:
-    /** Epoch */
-    epoch_t epoch() const;
-
-    /** Version */
-    const std::string & version() const;
-
-    /** Release */
-    const std::string & release() const;
-
-    /** String representation of Edition. */
-    std::string asString() const;
-
-  public:
-    /** Compare two Editions returning <tt>-1,0,1</tt>.
-     * \return <tt>-1,0,1</tt> if editions are <tt>\<,==,\></tt>.
-     *
-     * \attention An empty version or release string is not treated
-     * specialy. It's the least possible value. If you want an empty
-     * string treated as \c ANY, use \ref match.
-    */
-    static int compare( const Edition & lhs, const Edition & rhs );
-
-    /** */
-    int compare( const Edition & rhs ) const
-    { return compare( *this, rhs ); }
-
-    /** \ref compare functor.
-     * \see \ref RelCompare.
-    */
-    typedef zypp::Compare<Edition> Compare;
-
-    /** \ref Edition \ref Range based on \ref Compare.
-     * \see \ref RelCompare.
-    */
-    typedef Range<Edition> CompareRange;
-
-  public:
-    /** Match two Editions returning <tt>-1,0,1</tt>, treating empty
-     *  strings as \c ANY.
-     * \return <tt>-1,0,1</tt> if editions match <tt>\<,==,\></tt>.
-    */
-    static int match( const Edition & lhs, const Edition & rhs );
-
-    /** */
-    int match( const Edition & rhs ) const
-    { return match( *this, rhs ); }
-
-    /** \ref match functor.
-     * \see \ref RelCompare.
-    */
-    struct Match: public std::binary_function<Edition,Edition,int>
-    {
-      int operator()( const Edition & lhs, const Edition & rhs ) const
-      { return Edition::match( lhs, rhs ); }
-    };
-
-    /** \ref Edition \ref Range based on \ref Match.
-     * \see \ref RelCompare.
-    */
-    typedef Range<Edition, Match> MatchRange;
-
-  private:
-    /** Hides implementation */
-    struct Impl;
-    /** Pointer to implementation */
-    RW_pointer<Impl> _pimpl;
+     */
+      static const Edition noedition;
+
+    public:
+      /** Default ctor: \ref noedition. */
+      Edition() {}
+
+      /** Ctor taking edition as string. */
+      explicit Edition( sat::detail::IdType id_r )   : _str( sat::IdStr(id_r).c_str() ) {}
+      explicit Edition( const sat::IdStr & idstr_r ) : _str( idstr_r.c_str() ) {}
+      explicit Edition( const char * cstr_r )        : _str( cstr_r ) {}
+      explicit Edition( const std::string & str_r )  : _str( str_r ) {}
+
+      /** Ctor taking \a version_r, \a release_r and optional \a epoch_r */
+      Edition( const std::string & version_r,
+               const std::string & release_r,
+               epoch_t epoch_r = noepoch );
+
+      /** Ctor taking \a version_r, \a release_r and optional \a epoch_r as string. */
+      Edition( const std::string & version_r,
+               const std::string & release_r,
+               const std::string & epoch_r );
+
+    public:
+      /** Epoch */
+      epoch_t epoch() const;
+
+      /** Version */
+      const std::string & version() const;
+
+      /** Release */
+      const std::string & release() const;
+
+    public:
+      /** */
+      using sat::IdStrType<Edition>::compare;
+
+      /** Compare two Editions returning <tt>-1,0,1</tt>.
+       * \return <tt>-1,0,1</tt> if editions are <tt>\<,==,\></tt>.
+       *
+       * \attention An empty version or release string is not treated
+       * specialy. It's the least possible value. If you want an empty
+       * string treated as \c ANY, use \ref match.
+       */
+      static int compare( const Edition & lhs, const Edition & rhs )
+      { return lhs.compare( rhs ); }
+
+      /** \ref compare functor.
+       * \see \ref RelCompare.
+       */
+      typedef zypp::Compare<Edition> Compare;
+
+      /** \ref Edition \ref Range based on \ref Compare.
+       * \see \ref RelCompare.
+       */
+      typedef Range<Edition> CompareRange;
+
+    public:
+      /** Match two Editions returning <tt>-1,0,1</tt>, treating empty
+       *  version/release strings as \c ANY.
+       */
+      int match( const Edition & rhs )     const { return _doMatchI( rhs.idStr() ); }
+      int match( const sat::IdStr & rhs )  const { return _doMatchI( rhs ); }
+      int match( const char * rhs )        const { return _doMatchC( rhs ); }
+      int match( const std::string & rhs ) const { return _doMatchC( rhs.c_str() ); }
+
+      /** Match two Editions returning <tt>-1,0,1</tt>, treating empty
+       *  version/release strings as \c ANY.
+       * \return <tt>-1,0,1</tt> if editions match <tt>\<,==,\></tt>.
+       */
+      static int match( const Edition & lhs, const Edition & rhs )
+      { return lhs.match( rhs ); }
+
+      /** \ref match functor.
+       * \see \ref RelCompare.
+       */
+      struct Match: public std::binary_function<Edition,Edition,int>
+      {
+        int operator()( const Edition & lhs, const Edition & rhs ) const
+        { return Edition::match( lhs, rhs ); }
+      };
+
+      /** \ref Edition \ref Range based on \ref Match.
+       * \see \ref RelCompare.
+       */
+      typedef Range<Edition, Match> MatchRange;
+
+    private:
+      int _doCompareC( const char * rhs )     const;
+      int _doMatchI( const sat::IdStr & rhs ) const { return idStr().compareEQ( rhs ) ? 0 : _doMatchC( rhs.c_str() ); }
+      int _doMatchC( const char * rhs )       const;
+
+    private:
+      friend class sat::IdStrType<Edition>;
+      sat::IdStr _str;
   };
   ///////////////////////////////////////////////////////////////////
 
-  /** \relates Edition Stream output. */
-  inline std::ostream & operator<<( std::ostream & str, const Edition & obj )
-  { return str << obj.asString(); }
-
-  /** \name Comaprison based on epoch, version, and release. */
-  //@{
-  /** \relates Edition */
-  inline bool operator==( const Edition & lhs, const Edition & rhs )
-  { return compareByRel( Rel::EQ, lhs, rhs ); }
-
-  /** \relates Edition */
-  inline bool operator!=( const Edition & lhs, const Edition & rhs )
-  { return compareByRel( Rel::NE, lhs, rhs ); }
-
-  /** \relates Edition */
-  inline bool operator<( const Edition & lhs, const Edition & rhs )
-  { return compareByRel( Rel::LT, lhs, rhs ); }
-
-  /** \relates Edition */
-  inline bool operator<=( const Edition & lhs, const Edition & rhs )
-  { return compareByRel( Rel::LE, lhs, rhs ); }
-
-  /** \relates Edition */
-  inline bool operator>( const Edition & lhs, const Edition & rhs )
-  { return compareByRel( Rel::GT, lhs, rhs ); }
-
-  /** \relates Edition */
-  inline bool operator>=( const Edition & lhs, const Edition & rhs )
-  { return compareByRel( Rel::GE, lhs, rhs ); }
-  //@}
-
   /////////////////////////////////////////////////////////////////
 } // namespace zypp
 ///////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////
-namespace std
-{ /////////////////////////////////////////////////////////////////
-
-  /** \relates zypp::Edition Default to lexicographical order in std::container.*/
-  template<>
-    inline bool less<zypp::Edition>::operator()( const zypp::Edition & lhs, const zypp::Edition & rhs ) const
-    { return lhs.asString() < rhs.asString(); }
-
-  /** \relates zypp::Edition Lexicographical equal for std::container. */
-  template<>
-    inline bool equal_to<zypp::Edition>::operator()( const zypp::Edition & lhs, const zypp::Edition & rhs ) const
-    { return lhs.asString() == rhs.asString(); }
-
-  /////////////////////////////////////////////////////////////////
-} // namespace std
-///////////////////////////////////////////////////////////////////
-
 #endif // ZYPP_EDITION_H
index fc760bf..77ab52c 100644 (file)
@@ -36,6 +36,9 @@ namespace zypp
     public:
       /** \name Some builtin ResKind constants. */
       //@{
+      /** Value representing \c nokind (<tt>""</tt>)*/
+      static const ResKind nokind;
+
       static const ResKind atom;
       static const ResKind language;
       static const ResKind message;
@@ -50,14 +53,16 @@ namespace zypp
       //@}
 
     public:
+      /** Default ctor: \ref nokind */
       ResKind() {}
+      /** Ctor taking kind as string. */
       explicit ResKind( sat::detail::IdType id_r )   : _str( str::toLower(sat::IdStr(id_r).c_str()) ) {}
       explicit ResKind( const sat::IdStr & idstr_r ) : _str( str::toLower(idstr_r.c_str()) ) {}
       explicit ResKind( const char * cstr_r )        : _str( str::toLower(cstr_r) ) {}
       explicit ResKind( const std::string & str_r )  : _str( str::toLower(str_r) ) {}
 
     private:
-      int _doDompareC( const char * rhs )  const
+      int _doCompareC( const char * rhs )  const
       { return str::compareCI( _str.c_str(), rhs ); }
 
     private:
index 0f09e52..07a7c84 100644 (file)
@@ -338,7 +338,7 @@ namespace zypp
          }
          else if ( key == "VERSION" )
          {
-           _pimpl->product().edition = value;
+           _pimpl->product().edition = Edition( value );
          }
          else if ( key == "ARCH" )
          {
@@ -358,7 +358,7 @@ namespace zypp
          }
          else if ( key == "DISTVERSION" )
          {
-           _pimpl->product().distributionEdition = value;
+           _pimpl->product().distributionEdition = Edition( value );
          }
          else if ( key == "VENDOR" )
          {
index cad0c53..c1cd50b 100644 (file)
@@ -167,7 +167,7 @@ namespace zypp
       // xpath: /products/product/distribution-edition (+)
       if (reader_r->name() == "distribution-edition")
       {
-        _product->distributionEdition = reader_r.nodeText().asString();
+        _product->distributionEdition = Edition( reader_r.nodeText().asString() );
         return true;
       }
 
index 50ac32f..7bb5a9a 100644 (file)
@@ -234,7 +234,7 @@ std::string PackageImpl::sourcePkgName() const
 
 Edition PackageImpl::sourcePkgEdition() const
 {
-  return _repository->resolvableQuery().queryStringAttribute( _id, cache::attrPackageSourcePkgEdition() );
+  return Edition( _repository->resolvableQuery().queryStringAttribute( _id, cache::attrPackageSourcePkgEdition() ) );
 }
 
 /////////////////////////////////////////////////////////////////
index f18dcc9..4d15f90 100644 (file)
@@ -150,7 +150,7 @@ std::string ProductImpl::distributionName() const
 
 Edition ProductImpl::distributionEdition() const
 {
-  return _repository->resolvableQuery().queryStringAttribute( _id, cache::attrProductDistributionEdition() );
+  return Edition( _repository->resolvableQuery().queryStringAttribute( _id, cache::attrProductDistributionEdition() ) );
 }
 
 /////////////////////////////////////////////////////////////////
index 9d2870e..a6c23d9 100644 (file)
@@ -31,11 +31,11 @@ namespace zypp
      * the operations an \ref IdStr does. (incl. conversion to string types,
      * comparison with string types and stream output).
      *
-     * To disable any comparison, declare (but do not define) \ref _doDompareC
+     * To disable any comparison, declare (but do not define) \ref _doCompareC
      * in your class. If you need a different than the default lexicographical
-     * order, write your own \ref _doDompareC. If you can provide optimized
+     * order, write your own \ref _doCompareC. If you can provide optimized
      * comparison against IdStr or your class itself, \b additionally provide
-     * _doDompareI, and/or _doDompareD.
+     * _doCompareI, and/or _doCompareD.
      *
      * \code
      *    class CaseCmp : public sat::IdStrType<CaseCmp>
@@ -54,7 +54,7 @@ namespace zypp
      *        NoCaseCmp() {}
      *        explicit NoCaseCmp( const char * cstr_r ) : _str( cstr_r )  {}
      *      private:
-     *        int _doDompareC( const char * rhs )  const
+     *        int _doCompareC( const char * rhs )  const
      *        { return ::strcasecmp( _str.c_str(), rhs ); }
      *      private:
      *        friend class sat::IdStrType<NoCaseCmp>;
@@ -97,16 +97,16 @@ namespace zypp
         using base::SafeBool<Derived>::operator bool_type;
 
       public:
-        int compare( const Derived & rhs )     const { return self()._doDompareD( rhs ); }
-        int compare( const IdStrType & rhs )   const { return self()._doDompareD( rhs.self() ); }
-        int compare( const IdStr & rhs )       const { return self()._doDompareI( rhs ); }
-        int compare( const char * rhs )        const { return self()._doDompareC( rhs ); }
-        int compare( const std::string & rhs ) const { return self()._doDompareC( rhs.c_str() ); }
+        int compare( const Derived & rhs )     const { return self()._doCompareD( rhs ); }
+        int compare( const IdStrType & rhs )   const { return self()._doCompareD( rhs.self() ); }
+        int compare( const IdStr & rhs )       const { return self()._doCompareI( rhs ); }
+        int compare( const char * rhs )        const { return self()._doCompareC( rhs ); }
+        int compare( const std::string & rhs ) const { return self()._doCompareC( rhs.c_str() ); }
 
       private:
-        int _doDompareD( const Derived & rhs ) const { return self()._doDompareI( rhs.idStr() ); }
-        int _doDompareI( const IdStr & rhs )   const { return idStr().compareEQ( rhs ) ? true : self()._doDompareC( rhs.c_str() ); }
-        int _doDompareC( const char * rhs )    const { return idStr().compare( rhs ); }
+        int _doCompareD( const Derived & rhs ) const { return self()._doCompareI( rhs.idStr() ); }
+        int _doCompareI( const IdStr & rhs )   const { return idStr().compareEQ( rhs ) ? 0 : self()._doCompareC( rhs.c_str() ); }
+        int _doCompareC( const char * rhs )    const { return idStr().compare( rhs ); }
 
         friend base::SafeBool<Derived>::operator bool_type() const;
         bool boolTest() const { return ! empty(); }
index bfbbc4f..669ce30 100644 (file)
@@ -26,8 +26,6 @@ extern "C"
 
 #include "zypp/sat/detail/PoolImpl.h"
 #include "zypp/sat/Pool.h"
-#include "zypp/sat/Repo.h"
-#include "zypp/sat/Solvable.h"
 
 ///////////////////////////////////////////////////////////////////
 namespace zypp
index ed86789..1d5c15a 100644 (file)
@@ -125,10 +125,10 @@ namespace zypp
       return( sep ? sep+1 : ident );
     }
 
-    EvrId Solvable::edition() const
+    Edition Solvable::edition() const
     {
-      NO_SOLVABLE_RETURN( EvrId() );
-      return EvrId( _solvable->evr );
+      NO_SOLVABLE_RETURN( Edition() );
+      return Edition( _solvable->evr );
     }
 
     ArchId Solvable::arch() const
index 68e3d7d..95453a3 100644 (file)
@@ -79,7 +79,7 @@ namespace zypp
         IdStr        ident()    const;
         ResKind      kind()     const;
         std::string  name()     const;
-        EvrId        edition()  const;
+        Edition      edition()  const;
         ArchId       arch()     const;
         VendorId     vendor()   const;
 
index 9890843..f8a94a1 100644 (file)
@@ -106,8 +106,6 @@ namespace zypp
     ///////////////////////////////////////////////////////////////////
 
     ///////////////////////////////////////////////////////////////////
-    typedef IdStr NameId;
-    typedef IdStr EvrId;
     typedef IdStr ArchId;
     typedef IdStr VendorId;
     ///////////////////////////////////////////////////////////////////
index 75e5ba0..f37a2e0 100644 (file)
@@ -1029,7 +1029,7 @@ XMLFilesBackend::createProduct( const zypp::parser::xmlstore::XMLProductData & p
     impl->_type = parsed.type;
     impl->_short_name = parsed.short_name;
     impl->_dist_name = parsed.dist_name;
-    impl->_dist_version = parsed.dist_version;
+    impl->_dist_version = Edition( parsed.dist_version );
 
     if ( parsed.releasenotesurl.size() > 0 )
       impl->_release_notes_url = parsed.releasenotesurl;