Edition replaced by Edition of libzypp
authorStefan Schubert <schubi@suse.de>
Wed, 21 Dec 2005 16:32:53 +0000 (16:32 +0000)
committerStefan Schubert <schubi@suse.de>
Wed, 21 Dec 2005 16:32:53 +0000 (16:32 +0000)
16 files changed:
zypp/solver/detail/Dependency.cc
zypp/solver/detail/Dependency.h
zypp/solver/detail/Edition.cc [deleted file]
zypp/solver/detail/Edition.h [deleted file]
zypp/solver/detail/EditionPtr.h [deleted file]
zypp/solver/detail/Makefile.am
zypp/solver/detail/MatchPtr.h
zypp/solver/detail/OrDependency.cc
zypp/solver/detail/Package.cc
zypp/solver/detail/QueueItemConflict.cc
zypp/solver/detail/ResItem.h
zypp/solver/detail/Spec.cc
zypp/solver/detail/Spec.h
zypp/solver/detail/Version.cc
zypp/solver/detail/Version.h
zypp/solver/detail/XmlParser.cc

index 2169f71..44cdd01 100644 (file)
@@ -28,6 +28,7 @@
 #include <zypp/solver/detail/OrDependency.h>
 #include <zypp/solver/detail/Version.h>
 #include <zypp/Arch.h>
+#include <zypp/Edition.h>
 
 /////////////////////////////////////////////////////////////////////////
 namespace zypp 
@@ -203,7 +204,7 @@ namespace zypp
        res += dependency.relation().asString();
        res += " ";
       
-       res += dependency.edition()->asString();
+       res += dependency.edition().asString();
           }
           if (dependency.orDep()) res += " [OR]";
           if (dependency.preDep()) res += " [PRE]";
@@ -256,7 +257,7 @@ namespace zypp
       
       
       Dependency::Dependency (const string & name, const Relation & relation, const Resolvable::Kind & kind,
-       constChannelPtr channel, constEditionPtr edition, bool or_dep, bool pre_dep)
+       constChannelPtr channel, const Edition & edition, bool or_dep, bool pre_dep)
           : Spec (kind, name, edition)
           , _relation (relation)
           , _channel (channel)
@@ -295,7 +296,7 @@ namespace zypp
           tmp = node->getProp ("op", NULL);
           if (tmp) {
        _relation = Relation::parse(tmp);
-       setEpoch (node->getIntValueDefault ("epoch", -1));
+       setEpoch (node->getIntValueDefault ("epoch", Edition::noepoch));
        setVersion (node->getProp ("version"));
        setRelease (node->getProp ("release"));
           }
@@ -410,17 +411,17 @@ namespace zypp
            compare_ret = 1;
        }
           } else if (epoch() > 0 ) {
-       compare_ret = -1;
+       compare_ret = Edition::noepoch;
           }
       if (getenv ("SPEW_DEP")) fprintf (stderr, "epoch(%d), prov->epoch(%d) -> compare_ret %d\n", epoch(), prov->epoch(), compare_ret);
           if (compare_ret == 0) {
        if (GVersion.hasProperty (VERSION_PROP_ALWAYS_VERIFY_RELEASE)
            || (!(release().empty() || prov->release().empty()))) {
-           newdepspec = new Spec(kind(), "", -1, version(), release());
-           newprovspec = new Spec(prov->kind(), "", -1, prov->version(), prov->release());
+           newdepspec = new Spec(kind(), "", Edition::noepoch, version(), release());
+           newprovspec = new Spec(prov->kind(), "", Edition::noepoch, prov->version(), prov->release());
        } else {
-           newdepspec = new Spec(kind(), "", -1, version());
-           newprovspec = new Spec(prov->kind(), "", -1, prov->version());
+           newdepspec = new Spec(kind(), "", Edition::noepoch, version());
+           newprovspec = new Spec(prov->kind(), "", Edition::noepoch, prov->version());
        }
        compare_ret = GVersion.compare (newprovspec, newdepspec);
           }
index d1cc6ed..557d2af 100644 (file)
@@ -129,23 +129,23 @@ namespace zypp
           bool _pre_dep;
       
         public:
-      
+
           Dependency (const std::string & name,
          const Relation & relation,
          const Resolvable::Kind & kind = ResTraits<zypp::Package>::kind,
          constChannelPtr channel = NULL,
-         int epoch = -1,
+         int epoch = Edition::noepoch,
          const std::string & version = "",
          const std::string & release = "",
           const zypp::Arch & arch = zypp::Arch(),
          bool or_dep = false,
          bool pre_dep = false);
-      
+
           Dependency (const std::string & name,
          const Relation & relation,
-                      const Resolvable::Kind & kind = ResTraits<zypp::Package>::kind,
+          const Resolvable::Kind & kind = ResTraits<zypp::Package>::kind,
          constChannelPtr channel = NULL,
-         constEditionPtr edition = NULL,
+         const zypp::Edition & edition = zypp::Edition(),
          bool or_dep = false,
          bool pre_dep = false);
       
@@ -154,7 +154,7 @@ namespace zypp
           Dependency (constXmlNodePtr node);           //RCResItemDep *rc_xml_node_to_resItem_dep (const xmlNode *node);
       
           virtual ~Dependency();
-      
+       
           // ---------------------------------- I/O
       
           const xmlNodePtr asXmlNode (void) const;             // xmlNode *rc_resItem_dep_to_xml_node (RCResItemDep *dep_item);
diff --git a/zypp/solver/detail/Edition.cc b/zypp/solver/detail/Edition.cc
deleted file mode 100644 (file)
index 33e0266..0000000
+++ /dev/null
@@ -1,153 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* Edition.cc
- *
- * Definition of 'edition'
- *  contains epoch-version-release-arch
- *  and comparision functions
- *
- * Copyright (C) 2000-2002 Ximian, Inc.
- * Copyright (C) 2005 SUSE Linux Products GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#include <y2util/stringutil.h>
-
-#include <zypp/solver/detail/Edition.h>
-#include <zypp/solver/detail/Version.h>
-
-/////////////////////////////////////////////////////////////////////////
-namespace zypp 
-{ ///////////////////////////////////////////////////////////////////////
-  ///////////////////////////////////////////////////////////////////////
-  namespace solver
-  { /////////////////////////////////////////////////////////////////////
-    /////////////////////////////////////////////////////////////////////
-    namespace detail
-    { ///////////////////////////////////////////////////////////////////
-      
-      using namespace std;
-      
-      IMPL_BASE_POINTER(Edition);
-      
-      //---------------------------------------------------------------------------
-      
-      string
-      Edition::asString ( bool full ) const
-      {
-          return toString (*this, full);
-      }
-      
-      
-      string
-      Edition::toString ( const Edition & edition, bool full )
-      {
-          string res ("");
-      
-          if (edition._epoch >= 0) {
-       res += stringutil::numstring (edition._epoch);
-       res += ":";
-          }
-      
-          res += edition._version;
-          if (!edition._release.empty()) {
-       res += "-";
-       res += edition._release;
-          }
-      
-          if (full) {
-       res += ".";
-       res += edition._arch.asString();
-          }
-      
-          return res;
-      }
-      
-      
-      ostream &
-      Edition::dumpOn( ostream & str ) const
-      {
-          str << asString();
-          return str;
-      }
-      
-      
-      ostream&
-      operator<<( ostream& os, const Edition& edition)
-      {
-          return os << edition.asString();
-      }
-      
-      //---------------------------------------------------------------------------
-      
-      Edition::Edition( int epoch, const string & version, const string & release, const zypp::Arch & arch)
-          : _epoch (epoch)
-          , _version (version)
-          , _release (release)
-          , _arch (arch)
-      {
-      }
-      
-      
-      Edition::~Edition()
-      {
-      }
-      
-      
-      EditionPtr
-      Edition::copy (void) const
-      {
-          return new Edition (_epoch, _version, _release, _arch);
-      }
-      
-      
-      EditionPtr
-      Edition::fromString (const char *s)
-      {
-          return GVersion.parse (s);
-      }
-      
-      
-      bool
-      Edition::match( constEditionPtr edition ) const {
-      //fprintf (stderr, "<%s> match <%s>\n", asString().c_str(), edition->asString().c_str());
-          if (_epoch != edition->_epoch) return false;
-      //fprintf (stderr, "epoch ok\n");
-          if (_version != edition->_version) return false;
-      //fprintf (stderr, "version ok\n");
-          if (_release != edition->_release) return false;
-      //fprintf (stderr, "release ok\n");
-          if (_arch != edition->_arch) return false;
-      //fprintf (stderr, "arch ok\n");
-          return true;
-      }
-      
-      
-      bool
-      Edition::equals( constEditionPtr edition ) const {
-      //fprintf (stderr, "<%s> equals <%s>\n", asString().c_str(), edition->asString().c_str());
-          return match (edition);
-      }
-      
-      ///////////////////////////////////////////////////////////////////
-    };// namespace detail
-    /////////////////////////////////////////////////////////////////////
-    /////////////////////////////////////////////////////////////////////
-  };// namespace solver
-  ///////////////////////////////////////////////////////////////////////
-  ///////////////////////////////////////////////////////////////////////
-};// namespace zypp
-/////////////////////////////////////////////////////////////////////////
-
diff --git a/zypp/solver/detail/Edition.h b/zypp/solver/detail/Edition.h
deleted file mode 100644 (file)
index e72a1ed..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* Edition.h
- * Copyright (C) 2000-2002 Ximian, Inc.
- * Copyright (C) 2005 SUSE Linux Products GmbH
- *
- * Definition of 'edition'
- *  contains epoch-version-release-arch
- *  and comparision functions
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#ifndef _Edition_h
-#define _Edition_h
-
-#include <iosfwd>
-#include <string>
-
-#include <y2util/Ustring.h>
-
-#include <zypp/solver/detail/EditionPtr.h>
-#include <zypp/solver/detail/XmlNodePtr.h>
-#include <zypp/Arch.h>
-
-/////////////////////////////////////////////////////////////////////////
-namespace zypp 
-{ ///////////////////////////////////////////////////////////////////////
-  ///////////////////////////////////////////////////////////////////////
-  namespace solver
-  { /////////////////////////////////////////////////////////////////////
-    /////////////////////////////////////////////////////////////////////
-    namespace detail
-    { ///////////////////////////////////////////////////////////////////
-
-      ///////////////////////////////////////////////////////////////////
-      //
-      //       CLASS NAME : Edition
-      /**
-       *
-       **/
-      class Edition : public CountedRep {
-          REP_BODY(Edition);
-      
-        private:
-          int _epoch;
-          std::string _version;
-          std::string _release;
-          zypp::Arch _arch;
-      
-        public:
-      
-          //
-          // -1 resp. NULL values are treated as 'any'
-          //
-      
-          Edition( int epoch = -1, const std::string & version = "", const std::string & release = "", const Arch & arch = zypp::Arch());
-          virtual ~Edition();
-      
-          // ---------------------------------- I/O
-      
-          const XmlNodePtr asXmlNode (void) const;
-      
-          static std::string toString ( const Edition & edition, bool full = false );
-      
-          virtual std::ostream & dumpOn( std::ostream & str ) const;
-      
-          friend std::ostream& operator<<( std::ostream&, const Edition& );
-      
-          std::string asString ( bool full = false ) const;
-      
-          // ---------------------------------- accessors
-      
-          void setVersion (const std::string & version) { _version = version; }
-          void setRelease (const std::string & release) { _release = release; }
-          void setEpoch (int epoch) { _epoch = epoch; }
-          void setArch (const std::string & arch) { _arch = zypp::Arch(arch); }
-          void setArch (const zypp::Arch & arch) { _arch = arch; }
-      
-          const std::string & version() const { return _version; }
-          const std::string & release() const { return _release; }
-          const int epoch() const { return _epoch; }
-          bool hasEpoch() const { return _epoch >= 0; }
-          const zypp::Arch & arch() const { return _arch; }
-      
-          bool match( constEditionPtr edition ) const;
-          bool equals( constEditionPtr edition ) const;
-      
-          // ---------------------------------- accessors
-      
-          EditionPtr copy (void) const;
-          static EditionPtr fromString (const char *s);
-      
-      };
-      
-      ///////////////////////////////////////////////////////////////////
-    };// namespace detail
-    /////////////////////////////////////////////////////////////////////
-    /////////////////////////////////////////////////////////////////////
-  };// namespace solver
-  ///////////////////////////////////////////////////////////////////////
-  ///////////////////////////////////////////////////////////////////////
-};// namespace zypp
-/////////////////////////////////////////////////////////////////////////
-
-#endif // _Edition_h
diff --git a/zypp/solver/detail/EditionPtr.h b/zypp/solver/detail/EditionPtr.h
deleted file mode 100644 (file)
index 3117f8d..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* EditionPtr.h
- *
- * Copyright (C) 2005 SUSE Linux Products GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#ifndef _EditionPtr_h
-#define _EditionPtr_h
-
-#include <y2util/RepDef.h>
-
-/////////////////////////////////////////////////////////////////////////
-namespace zypp 
-{ ///////////////////////////////////////////////////////////////////////
-  ///////////////////////////////////////////////////////////////////////
-  namespace solver
-  { /////////////////////////////////////////////////////////////////////
-    /////////////////////////////////////////////////////////////////////
-    namespace detail
-    { ///////////////////////////////////////////////////////////////////
-      
-      ///////////////////////////////////////////////////////////////////
-      //       CLASS NAME : EditionPtr
-      //       CLASS NAME : constEditionPtr
-      ///////////////////////////////////////////////////////////////////
-      DEFINE_BASE_POINTER(Edition);
-
-      ///////////////////////////////////////////////////////////////////
-    };// namespace detail
-    /////////////////////////////////////////////////////////////////////
-    /////////////////////////////////////////////////////////////////////
-  };// namespace solver
-  ///////////////////////////////////////////////////////////////////////
-  ///////////////////////////////////////////////////////////////////////
-};// namespace zypp
-/////////////////////////////////////////////////////////////////////////        
-
-#endif // _EditionPtr_h
index f0460ec..86f6207 100644 (file)
@@ -14,8 +14,6 @@ include_HEADERS = \
        debug.h                         \
        utils.h                         \
        extract.h                       \
-       Edition.h                       \
-       EditionPtr.h                    \
        Hash.h                          \
        Spec.h                          \
        SpecPtr.h                       \
@@ -100,7 +98,6 @@ noinst_LTLIBRARIES = lib@PACKAGE@_solver_detail.la
 lib@PACKAGE@_solver_detail_la_SOURCES =                        \
        utils.cc                                        \
        debug.cc                                        \
-       Edition.cc                                      \
        Spec.cc                                         \
        Channel.cc                                      \
        Subscription.cc                                 \
index 1881240..f6d579a 100644 (file)
@@ -22,7 +22,6 @@
 #define _MatchPtr_h
 
 #include <y2util/RepDef.h>
-#include <zypp/solver/detail/Edition.h>
 
 /////////////////////////////////////////////////////////////////////////
 namespace zypp 
index 9c480e1..3b23c86 100644 (file)
@@ -25,6 +25,8 @@
 
 #include <zypp/solver/detail/OrDependency.h>
 #include <zypp/solver/detail/Dependency.h>
+#include <zypp/solver/detail/Version.h>
+
 
 /////////////////////////////////////////////////////////////////////////
 namespace zypp 
@@ -196,7 +198,7 @@ namespace zypp
        SpecPtr spec;
        char *name;
        Relation relation = Relation::Any;
-       EditionPtr edition = NULL;
+       zypp::Edition edition;
       
        /* grab the name */
       
@@ -242,14 +244,15 @@ namespace zypp
            /* e .. p is the epoch:version-release */
            vstr = strndup (e, p - e);
       
-           EditionPtr edition = Edition::fromString (vstr);
+           zypp::Edition edition = GVersion.parse (vstr);
       
            free ((void *)vstr);
       
        }
-      
-       DependencyPtr dep = new Dependency (name, relation, ResTraits<zypp::Package>::kind, NULL, edition);
-      
+
+        
+       DependencyPtr dep = new Dependency (name, relation, ResTraits<zypp::Package>::kind, NULL, edition );
+
        out_dep.push_back (dep);
        free ((void *)name);
       
index c72fe8b..095ec9e 100644 (file)
@@ -380,7 +380,7 @@ namespace zypp
       
           if (version) {
       
-       setEpoch (epoch ? atoi (epoch) : -1);
+       setEpoch (epoch ? atoi (epoch) : Edition::noepoch);
        setVersion (version);
        setRelease (release);
       
index 3770e52..ed06278 100644 (file)
@@ -198,7 +198,7 @@ namespace zypp
        UpgradeCandidateInfo upgrade_info;
        upgrade_info.context = info->context;
       
-       DependencyPtr maybe_upgrade_dep = new Dependency (resItem->name(), Relation::Any, ResTraits<zypp::Package>::kind, new Channel (CHANNEL_TYPE_NONSYSTEM), -1);
+       DependencyPtr maybe_upgrade_dep = new Dependency (resItem->name(), Relation::Any, ResTraits<zypp::Package>::kind, new Channel (CHANNEL_TYPE_NONSYSTEM), Edition::noepoch);
        info->world->foreachProvidingResItem (maybe_upgrade_dep, upgrade_candidates_cb, (void *)&upgrade_info);
       
       #endif
index a3f2a48..9b85fdb 100644 (file)
@@ -31,6 +31,7 @@
 #include <zypp/solver/detail/Dependency.h>
 #include <zypp/solver/detail/Channel.h>
 #include <zypp/ResObject.h>
+#include <zypp/Edition.h>
 
 /////////////////////////////////////////////////////////////////////////
 namespace zypp 
@@ -89,7 +90,7 @@ namespace zypp
       
         public:
       
-          ResItem(const Resolvable::Kind & kind, const std::string & name, int epoch = -1, const std::string & version = "", const std::string & release = "", const zypp::Arch & arch = zypp::Arch());
+          ResItem(const Resolvable::Kind & kind, const std::string & name, int epoch = Edition::noepoch, const std::string & version = "", const std::string & release = "", const zypp::Arch & arch = zypp::Arch());
 
           ResItem(const ResObject::Ptr & resObject);
           ResItem(const XmlNodePtr node);
@@ -172,8 +173,8 @@ namespace zypp
           const std::string name() const { return _name; }
           void setName (const std::string & name) { _name = Name(name.c_str()); }
       
-          constEditionPtr edition() const { return _edition; }
-          void setEdition (constEditionPtr edition) { _edition = edition->copy(); }
+          const Edition & edition() const { return _edition; }
+          void setEdition (const Edition & edition) { _edition = edition }
 #endif
       
       };
index 686159a..d060c18 100644 (file)
@@ -65,12 +65,19 @@ namespace zypp
       
           res += spec.name();
       
-          string ed = spec.edition()->asString (full);
-          if (!ed.empty()) {
+          string ed = spec.edition().asString();
+          if (!ed.empty() &&
+              ed != "EDITION-UNSPEC") {
        res += "-";
        res += ed;
           }
-      
+
+          if (spec.arch() != zypp::Arch_noarch) {
+              res += ".";
+              res += spec.arch().asString();
+          }
+          
+
           return res;
       }
       
@@ -91,10 +98,11 @@ namespace zypp
       
       //---------------------------------------------------------------------------
       
-      Spec::Spec (const Resolvable::Kind & kind, const string & name, constEditionPtr edition)
+      Spec::Spec (const Resolvable::Kind & kind, const string & name, const Edition & edition, const zypp::Arch & arch)
           : _kind (kind)
           , _name (Name (name))
-          , _edition (edition == NULL ? new Edition() : edition->copy())
+          , _edition (edition)
+          , _arch (arch)
       {
       }
       
@@ -102,7 +110,8 @@ namespace zypp
       Spec::Spec ( const Resolvable::Kind & kind, const string & name, int epoch, const string & version, const string & release, const zypp::Arch & arch)
           : _kind (kind)
           , _name (Name (name))
-          , _edition (new Edition (epoch, version, release, arch))
+          , _edition (Edition (version, release, epoch))
+          , _arch(arch)
       {
       }
       
@@ -165,13 +174,13 @@ namespace zypp
       HashValue
       Spec::hash (void) const
       {
-          HashValue ret = _edition->epoch() + 1;
+          HashValue ret = _edition.epoch() + 1;
           const char *spec_strs[3], *p;
           int i;
       
           spec_strs[0] = _name.asString().c_str();
-          spec_strs[1] = _edition->version().c_str();
-          spec_strs[2] = _edition->release().c_str();
+          spec_strs[1] = _edition.version().c_str();
+          spec_strs[2] = _edition.release().c_str();
       
           for (i = 0; i < 3; ++i) {
        p = spec_strs[i];
@@ -206,7 +215,7 @@ namespace zypp
       Spec::match(constSpecPtr spec) const {
           return ((_kind == spec->kind())
                && (_name == spec->name())
-       && _edition->match (spec->edition()));
+       && Edition::compare( _edition, spec->edition()) == 0);
       }
       
       
@@ -215,8 +224,30 @@ namespace zypp
       //fprintf (stderr, "<%s> equals <%s>\n", asString(true).c_str(), spec->asString(true).c_str());
           return ((_kind == spec->kind())
                && (_name == spec->name())
-       && _edition->equals(spec->edition()));
+       && Edition::compare( _edition, spec->edition()) == 0);
       }
+
+      void Spec::setVersion (const std::string & version) {
+          Edition newEdition(version,
+                             _edition.release(),
+                             _edition.epoch());
+          _edition = newEdition;
+      }
+
+      void Spec::setRelease (const std::string & release) {
+          Edition newEdition(_edition.version(),
+                             release,
+                             _edition.epoch());
+          _edition = newEdition;
+      }
+
+      void Spec::setEpoch (int epoch) {
+          Edition newEdition(_edition.version(),
+                             _edition.release(),
+                             epoch);
+          _edition = newEdition;
+      }            
+        
       
       ///////////////////////////////////////////////////////////////////
     };// namespace detail
index 8386e66..16e13f6 100644 (file)
@@ -31,7 +31,7 @@
 #include <zypp/solver/detail/Hash.h>
 #include <zypp/solver/detail/SpecPtr.h>
 #include <zypp/solver/detail/XmlNode.h>
-#include <zypp/solver/detail/Edition.h>
+#include <zypp/Edition.h>
 #include <zypp/ResObject.h>
 
 /////////////////////////////////////////////////////////////////////////
@@ -77,19 +77,20 @@ class Name : public Ustring {
         private:
           Resolvable::Kind _kind;
           Name _name;
-          EditionPtr _edition;
+          Edition _edition;
+          Arch _arch;
       
         public:
           typedef std::list<Spec> SpecList;
       
           Spec( const Resolvable::Kind & kind,
          const std::string & name,
-         int epoch = -1,
+         int epoch = Edition::noepoch,
          const std::string & version = "",
          const std::string & release = "",
          const zypp::Arch & arch = Arch());
       
-          Spec (const Resolvable::Kind & kind, const std::string & name, constEditionPtr edition);
+          Spec (const Resolvable::Kind & kind, const std::string & name, const Edition & edition, const zypp::Arch & arch = Arch());
       
           Spec (constXmlNodePtr node);
       
@@ -109,19 +110,19 @@ class Name : public Ustring {
       
           // ---------------------------------- accessors
       
-          const std::string & version() const { return _edition->version(); }
-          void setVersion (const std::string & version) { _edition->setVersion (version); }
+          const std::string & version() const { return _edition.version(); }
+          void setVersion (const std::string & version);
       
-          const std::string & release() const { return _edition->release(); }
-          void setRelease (const std::string & release) { _edition->setRelease (release); }
+          const std::string & release() const { return _edition.release(); }
+          void setRelease (const std::string & release);
       
-          const int epoch() const { return _edition->epoch(); }
-          void setEpoch (int epoch) { _edition->setEpoch (epoch); }
-          bool hasEpoch() const { return _edition->hasEpoch(); }
+          const int epoch() const { return _edition.epoch(); }
+          void setEpoch (int epoch);
+          bool hasEpoch() const { return _edition.epoch() > 0; }
       
-          const zypp::Arch & arch() const { return _edition->arch(); }
-          void setArch (const Arch & arch) { _edition->setArch (arch); }
-          void setArch (const std::string & arch) { _edition->setArch (arch); }
+          const zypp::Arch & arch() const { return _arch; }
+          void setArch (const Arch & arch) { _arch = arch; }
+          void setArch (const std::string & arch) { _arch = Arch(arch); }
       
           const Resolvable::Kind & kind() const { return _kind; }
           void setKind (const Resolvable::Kind & kind) { _kind = kind; }
@@ -129,8 +130,8 @@ class Name : public Ustring {
           const std::string name() const { return _name; }
           void setName (const std::string & name) { _name = Name(name.c_str()); }
       
-          constEditionPtr edition() const { return _edition; }
-          void setEdition (constEditionPtr edition) { _edition = edition->copy(); }
+          const Edition & edition() const { return _edition; }
+          void setEdition (const Edition & edition) { _edition = edition; }
       
           // calculate hash
           HashValue hash (void) const;
index d611ed8..0e59e01 100644 (file)
@@ -69,15 +69,17 @@ namespace zypp
       
       //---------------------------------------------------------------------------
       
-      static EditionPtr
+      static Edition 
       rpm_parse (const char *input)
       {
           const char *vptr = NULL, *rptr = NULL;
       
           if (input == NULL || *input == 0)
-       return NULL;
+          {
+              return Edition();
+          }
       
-          int epoch = -1;
+          int epoch = Edition::noepoch;
           const char *version;
           const char *release;
       
@@ -89,7 +91,7 @@ namespace zypp
       
        if (endptr != vptr) {
            /* No epoch here, just a : in the version string */
-           epoch = -1;
+           epoch = Edition::noepoch;
            vptr = input;
        } else {
            vptr++;
@@ -107,7 +109,7 @@ namespace zypp
        release = NULL;
           }
       
-          EditionPtr edition = new Edition(epoch, version, release, zypp::Arch());
+          Edition edition( version, release, epoch);
       
           return edition;
       }
index 9d15878..162e5e1 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <y2util/Ustring.h>
 #include <zypp/solver/detail/Spec.h>
+#include <zypp/Edition.h>
 
 /////////////////////////////////////////////////////////////////////////
 namespace zypp 
@@ -78,7 +79,7 @@ namespace zypp
       
           unsigned int _properties;
       
-          EditionPtr (*_parse)(const char *input);
+          Edition  (*_parse)(const char *input);
       
           // compare uses SpecPtr and takes name into account
           int (*_compare)(constSpecPtr a, constSpecPtr b);
@@ -105,7 +106,7 @@ namespace zypp
           // compare uses SpecPtr and takes name into account
           int compare (constSpecPtr a, constSpecPtr b) const { return (*_compare) (a, b); }
       
-          EditionPtr parse (const char *input) const { return (*_parse)(input); }
+          Edition  parse (const char *input) const { return (*_parse)(input); }
       
           bool hasProperty (unsigned int property) const { return (_properties & property) != 0; }
       
index 9f69854..b256424 100644 (file)
@@ -52,10 +52,10 @@ namespace zypp
           bool op_present = false;
           /* Temporary variables dependent upon the presense of an 'op' attribute */
           const char *name = NULL;
-          int epoch = -1;
+          int epoch = Edition::noepoch;
           string version;
           string release;
-          string arch;
+          string arch = "";
           Relation relation = Relation::Any;
       
           *is_obsolete = false;
@@ -79,7 +79,14 @@ namespace zypp
       
           /* FIXME: should get Channel from XML */
           /* FIXME: should get Kind from XML */
-          return new Dependency (name, relation, ResTraits<zypp::Package>::kind, new Channel(CHANNEL_TYPE_ANY), epoch, version, release, zypp::Arch(arch));
+          if ( std::strlen(arch.c_str()) > 0)
+          {
+              return new Dependency (name, relation, ResTraits<zypp::Package>::kind, new Channel(CHANNEL_TYPE_ANY), epoch, version, release, zypp::Arch(arch));
+          }
+          else
+          {
+              return new Dependency (name, relation, ResTraits<zypp::Package>::kind, new Channel(CHANNEL_TYPE_ANY), epoch, version, release, zypp::Arch_noarch);
+          }              
       }