--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+
+#include <map>
+#include "zypp/base/Exception.h"
+#include "RepoType.h"
+
+namespace zypp
+{
+namespace repo
+{
+
+ static std::map<std::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::map<std::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<Type, std::string> _table;
+ if ( _table.empty() )
+ {
+ // initialize it
+ _table[RPMMD_e] = "rpm-md";
+ _table[YAST2_e] = "yast2";
+ _table[NONE_e] = "NONE";
+ }
+ return _table[_type];
+ }
+
+
+ } // ns repo
+} // ns zypp
+
+// vim: set ts=2 sts=2 sw=2 et ai:
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+
+#ifndef ZYPP_REPO_TYPE_H_
+#define ZYPP_REPO_TYPE_H_
+
+#include <iosfwd>
+#include<string>
+
+namespace zypp
+{
+ namespace repo
+ {
+
+ /**
+ * \short Repository type enumeration
+ *
+ * Repositories can be from varous types
+ * ...
+ */
+ struct RepoType
+ {
+ static const RepoType RPMMD;
+ static const RepoType YAST2;
+ //static const RepoType NONE;
+
+ enum Type
+ {
+ NONE_e,
+ RPMMD_e,
+ YAST2_e
+ };
+
+ RepoType(Type type) : _type(type) {}
+
+ explicit RepoType(const std::string & strval_r);
+
+ const Type toEnum() const { return _type; }
+
+ RepoType::Type parse(const std::string & strval_r);
+
+ const std::string & asString() const;
+
+ Type _type;
+ };
+
+
+ inline std::ostream & operator<<( std::ostream & str, const RepoType & obj )
+ { return str << obj.asString(); }
+
+ inline bool operator==(const RepoType & obj1, const RepoType & obj2)
+ { return obj1._type == obj2._type; }
+
+
+ } // ns repo
+} // ns zypp
+
+#endif
+
+// vim: set ts=2 sts=2 sw=2 et ai: