Dep.cc

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #include <map>
00013 
00014 #include "zypp/base/Exception.h"
00015 #include "zypp/base/String.h"
00016 
00017 #include "zypp/Dep.h"
00018 
00020 namespace zypp
00021 { 
00022 
00023   namespace
00024   {
00025 
00026     std::map<std::string,Dep::for_use_in_switch> _table;
00027 
00028     Dep::for_use_in_switch parse( const std::string & strval_r )
00029     {
00030       if ( _table.empty() )
00031         {
00032           // initialize it
00033           _table["provides"]    = Dep::PROVIDES_e;
00034           _table["prerequires"] = Dep::PREREQUIRES_e;
00035           _table["requires"]    = Dep::REQUIRES_e;
00036           _table["conflicts"]   = Dep::CONFLICTS_e;
00037           _table["obsoletes"]   = Dep::OBSOLETES_e;
00038           _table["recommends"]  = Dep::RECOMMENDS_e;
00039           _table["suggests"]    = Dep::SUGGESTS_e;
00040           _table["freshens"]    = Dep::FRESHENS_e;
00041           _table["enhances"]    = Dep::ENHANCES_e;
00042           _table["supplements"] = Dep::SUPPLEMENTS_e;
00043         }
00044 
00045       std::map<std::string,Dep::for_use_in_switch>::const_iterator it
00046       = _table.find( str::toLower( strval_r ) );
00047       if ( it == _table.end() )
00048         {
00049           ZYPP_THROW( Exception("Dep parse: illegal string value '"+strval_r+"'") );
00050         }
00051       return it->second;
00052     }
00053   }
00054 
00056 
00057   const Dep Dep::PROVIDES   ( Dep::PROVIDES_e );
00058   const Dep Dep::PREREQUIRES( Dep::PREREQUIRES_e );
00059   const Dep Dep::REQUIRES   ( Dep::REQUIRES_e );
00060   const Dep Dep::CONFLICTS  ( Dep::CONFLICTS_e );
00061   const Dep Dep::OBSOLETES  ( Dep::OBSOLETES_e );
00062   const Dep Dep::RECOMMENDS ( Dep::RECOMMENDS_e );
00063   const Dep Dep::SUGGESTS   ( Dep::SUGGESTS_e );
00064   const Dep Dep::FRESHENS   ( Dep::FRESHENS_e );
00065   const Dep Dep::ENHANCES   ( Dep::ENHANCES_e );
00066   const Dep Dep::SUPPLEMENTS( Dep::SUPPLEMENTS_e );
00067 
00069   //
00070   //    METHOD NAME : Dep::Dep
00071   //    METHOD TYPE : Ctor
00072   //
00073   Dep::Dep( const std::string & strval_r )
00074   : _type( parse( strval_r ) )
00075   {}
00076 
00078   //
00079   //    METHOD NAME : Dep::asString
00080   //    METHOD TYPE : const std::string &
00081   //
00082   const std::string & Dep::asString() const
00083   {
00084     static std::map<for_use_in_switch,std::string> _table;
00085     if ( _table.empty() )
00086       {
00087         // initialize it
00088         _table[PROVIDES_e]    = "provides";
00089         _table[PREREQUIRES_e] = "prerequires";
00090         _table[REQUIRES_e]    = "requires";
00091         _table[CONFLICTS_e]   = "conflicts";
00092         _table[OBSOLETES_e]   = "obsoletes";
00093         _table[RECOMMENDS_e]  = "recommends";
00094         _table[SUGGESTS_e]    = "suggests";
00095         _table[FRESHENS_e]    = "freshens";
00096         _table[ENHANCES_e]    = "enhances";
00097         _table[SUPPLEMENTS_e] = "supplements";
00098       }
00099     return _table[_type];
00100   }
00101 
00103 } // namespace zypp

Generated on Thu Jul 6 00:07:20 2006 for zypp by  doxygen 1.4.6