Author: dmacvicar
Date: Mon Jun 4 16:23:47 2007
New Revision: 5663
URL: http://svn.opensuse.org/viewcvs/zypp?rev=5663&view=rev
Log:
- Class to replace the strings "yum" and "yast" everywhere.
- They are safer, as can represent more than one string rep.
- can be used in switches.
Added:
trunk/libzypp/zypp2/repo/RepoType.cc
trunk/libzypp/zypp2/repo/RepoType.h
Modified:
trunk/libzypp/zypp2/CMakeLists.txt
Modified: trunk/libzypp/zypp2/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/CMakeLists.txt?rev=5663&r1=5662&r2=5663&view=diff
==============================================================================
--- trunk/libzypp/zypp2/CMakeLists.txt (original)
+++ trunk/libzypp/zypp2/CMakeLists.txt Mon Jun 4 16:23:47 2007
@@ -79,12 +79,14 @@
repo/dummy.cc
repo/RepositoryImpl.cc
repo/RepoException.cc
+ repo/RepoType.cc
)
SET( zypp2_repository_HEADERS
repo/dummy.h
repo/RepositoryImpl.h
repo/RepoException.h
+ repo/RepoType.h
)
SET( zypp2_repository_cached_SRCS
Added: trunk/libzypp/zypp2/repo/RepoType.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/repo/RepoType.cc?rev=5663&view=auto
==============================================================================
--- trunk/libzypp/zypp2/repo/RepoType.cc (added)
+++ trunk/libzypp/zypp2/repo/RepoType.cc Mon Jun 4 16:23:47 2007
@@ -0,0 +1,72 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+
+#include <map>
+#include "zypp/base/Exception.h"
+#include "RepoType.h"
+
+namespace zypp
+{
+namespace repo
+{
+
+ static std::mapstd::string,RepoType::Type _table;
+
+ const RepoType RepoType::RPMMD(RepoType::RPMMD_e);
+ const RepoType RepoType::YAST2(RepoType::YAST2_e);
+ //const RepoType RepoType::NONE(RepoType::NONE_e);
+
+ RepoType::RepoType(const std::string & strval_r)
+ : _type(parse(strval_r))
+ {}
+
+ RepoType::Type RepoType::parse(const std::string & strval_r)
+ {
+ if (_table.empty())
+ {
+ // initialize it
+ _table["repomd"] = RepoType::RPMMD_e;
+ _table["rpmmd"] = RepoType::RPMMD_e;
+ _table["rpm-md"] = RepoType::RPMMD_e;
+ _table["yum"] = RepoType::RPMMD_e;
+ _table["susetags"] = RepoType::YAST2_e;
+ _table["yast"] = RepoType::YAST2_e;
+ _table["yast2"] = RepoType::YAST2_e;
+ _table["NONE"] = _table["none"] = RepoType::NONE_e;
+ }
+
+ std::mapstd::string,RepoType::Type::const_iterator it
+ = _table.find(strval_r);
+ if (it == _table.end())
+ {
+ ZYPP_THROW(Exception(
+ "RepoType parse: illegal string value '" + strval_r + "'"));
+ }
+ return it->second;
+ }
+
+
+ const std::string & RepoType::asString() const
+ {
+ static std::map