1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
15 #include <zypp/base/Exception.h>
16 #include <zypp/base/Gettext.h>
17 #include <zypp/base/String.h>
21 ///////////////////////////////////////////////////////////////////
23 { /////////////////////////////////////////////////////////////////
27 inline Dep::for_use_in_switch parse( const std::string & strval_r )
29 const std::map<std::string,Dep::for_use_in_switch> _table = {
30 { "provides", Dep::PROVIDES_e },
31 { "prerequires", Dep::PREREQUIRES_e },
32 { "requires", Dep::REQUIRES_e },
33 { "conflicts", Dep::CONFLICTS_e },
34 { "obsoletes", Dep::OBSOLETES_e },
35 { "recommends", Dep::RECOMMENDS_e },
36 { "suggests", Dep::SUGGESTS_e },
37 { "enhances", Dep::ENHANCES_e },
38 { "supplements", Dep::SUPPLEMENTS_e }
41 auto it = _table.find( str::toLower( strval_r ) );
42 if ( it == _table.end() )
44 ZYPP_THROW( Exception("Dep parse: illegal string value '"+strval_r+"'") );
50 ///////////////////////////////////////////////////////////////////
52 const Dep Dep::PROVIDES ( Dep::PROVIDES_e );
53 const Dep Dep::PREREQUIRES( Dep::PREREQUIRES_e );
54 const Dep Dep::REQUIRES ( Dep::REQUIRES_e );
55 const Dep Dep::CONFLICTS ( Dep::CONFLICTS_e );
56 const Dep Dep::OBSOLETES ( Dep::OBSOLETES_e );
57 const Dep Dep::RECOMMENDS ( Dep::RECOMMENDS_e );
58 const Dep Dep::SUGGESTS ( Dep::SUGGESTS_e );
59 const Dep Dep::ENHANCES ( Dep::ENHANCES_e );
60 const Dep Dep::SUPPLEMENTS( Dep::SUPPLEMENTS_e );
62 ///////////////////////////////////////////////////////////////////
64 // METHOD NAME : Dep::Dep
67 Dep::Dep( const std::string & strval_r )
68 : _type( parse( strval_r ) )
71 ///////////////////////////////////////////////////////////////////
73 // METHOD NAME : Dep::asString
74 // METHOD TYPE : const std::string &
76 const std::string & Dep::asString() const
78 static const std::map<for_use_in_switch,std::string> _table = {
79 { PROVIDES_e, "provides" },
80 { PREREQUIRES_e, "prerequires" },
81 { REQUIRES_e, "requires" },
82 { CONFLICTS_e, "conflicts" },
83 { OBSOLETES_e, "obsoletes" },
84 { RECOMMENDS_e, "recommends" },
85 { SUGGESTS_e, "suggests" },
86 { ENHANCES_e, "enhances" },
87 { SUPPLEMENTS_e, "supplements" }
89 return _table.at(_type);
92 std::string Dep::asUserString() const
96 case PROVIDES_e: return _("Provides"); break;
97 case PREREQUIRES_e: return _("Prerequires"); break;
98 case REQUIRES_e: return _("Requires"); break;
99 case CONFLICTS_e: return _("Conflicts"); break;
100 case OBSOLETES_e: return _("Obsoletes"); break;
101 case RECOMMENDS_e: return _("Recommends"); break;
102 case SUGGESTS_e: return _("Suggests"); break;
103 case ENHANCES_e: return _("Enhances"); break;
104 case SUPPLEMENTS_e: return _("Supplements"); break;
106 return "<missing translation>";
109 /////////////////////////////////////////////////////////////////
111 ///////////////////////////////////////////////////////////////////