Dont mark failed patch scripts as installed.
[platform/upstream/libzypp.git] / zypp / Dep.cc
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/Dep.cc
10  *
11 */
12 #include <map>
13 #include <iostream>
14
15 #include "zypp/base/Exception.h"
16 #include "zypp/base/String.h"
17
18 #include "zypp/Dep.h"
19
20 ///////////////////////////////////////////////////////////////////
21 namespace zypp
22 { /////////////////////////////////////////////////////////////////
23
24   namespace
25   {
26
27     std::map<std::string,Dep::for_use_in_switch> _table;
28
29     Dep::for_use_in_switch parse( const std::string & strval_r )
30     {
31       if ( _table.empty() )
32         {
33           // initialize it
34           _table["provides"]    = Dep::PROVIDES_e;
35           _table["prerequires"] = Dep::PREREQUIRES_e;
36           _table["requires"]    = Dep::REQUIRES_e;
37           _table["conflicts"]   = Dep::CONFLICTS_e;
38           _table["obsoletes"]   = Dep::OBSOLETES_e;
39           _table["recommends"]  = Dep::RECOMMENDS_e;
40           _table["suggests"]    = Dep::SUGGESTS_e;
41           _table["freshens"]    = Dep::FRESHENS_e;
42           _table["enhances"]    = Dep::ENHANCES_e;
43           _table["supplements"] = Dep::SUPPLEMENTS_e;
44         }
45
46       std::map<std::string,Dep::for_use_in_switch>::const_iterator it
47       = _table.find( str::toLower( strval_r ) );
48       if ( it == _table.end() )
49         {
50           ZYPP_THROW( Exception("Dep parse: illegal string value '"+strval_r+"'") );
51         }
52       return it->second;
53     }
54   }
55
56   ///////////////////////////////////////////////////////////////////
57
58   const Dep Dep::PROVIDES   ( Dep::PROVIDES_e );
59   const Dep Dep::PREREQUIRES( Dep::PREREQUIRES_e );
60   const Dep Dep::REQUIRES   ( Dep::REQUIRES_e );
61   const Dep Dep::CONFLICTS  ( Dep::CONFLICTS_e );
62   const Dep Dep::OBSOLETES  ( Dep::OBSOLETES_e );
63   const Dep Dep::RECOMMENDS ( Dep::RECOMMENDS_e );
64   const Dep Dep::SUGGESTS   ( Dep::SUGGESTS_e );
65   const Dep Dep::FRESHENS   ( Dep::FRESHENS_e );
66   const Dep Dep::ENHANCES   ( Dep::ENHANCES_e );
67   const Dep Dep::SUPPLEMENTS( Dep::SUPPLEMENTS_e );
68
69   ///////////////////////////////////////////////////////////////////
70   //
71   //    METHOD NAME : Dep::Dep
72   //    METHOD TYPE : Ctor
73   //
74   Dep::Dep( const std::string & strval_r )
75   : _type( parse( strval_r ) )
76   {}
77
78   ///////////////////////////////////////////////////////////////////
79   //
80   //    METHOD NAME : Dep::asString
81   //    METHOD TYPE : const std::string &
82   //
83   const std::string & Dep::asString() const
84   {
85     static std::map<for_use_in_switch,std::string> _table;
86     if ( _table.empty() )
87       {
88         // initialize it
89         _table[PROVIDES_e]    = "provides";
90         _table[PREREQUIRES_e] = "prerequires";
91         _table[REQUIRES_e]    = "requires";
92         _table[CONFLICTS_e]   = "conflicts";
93         _table[OBSOLETES_e]   = "obsoletes";
94         _table[RECOMMENDS_e]  = "recommends";
95         _table[SUGGESTS_e]    = "suggests";
96         _table[FRESHENS_e]    = "freshens";
97         _table[ENHANCES_e]    = "enhances";
98         _table[SUPPLEMENTS_e] = "supplements";
99       }
100     return _table[_type];
101   }
102
103   /////////////////////////////////////////////////////////////////
104 } // namespace zypp
105 ///////////////////////////////////////////////////////////////////