libzypp 17.37.17
ServiceType.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
9
10#include <iostream>
11#include <map>
14#include "ServiceType.h"
15
16namespace zypp
17{
18 namespace repo
19 {
21 namespace
22 {
23 static NamedValue<ServiceType::Type> & table()
24 {
25 static NamedValue<ServiceType::Type> & _t( *new NamedValue<ServiceType::Type> );
26 if ( _t.empty() )
27 {
28 _t( ServiceType::RIS_e ) | "ris" |"RIS"|"nu"|"NU";
29 _t( ServiceType::PLUGIN_e ) | "plugin" |"PLUGIN";
30 _t( ServiceType::NONE_e ) | "N/A" |"n/a"|"NONE"|"none";
31 }
32 return _t;
33 }
34 } // namespace
36
37 const ServiceType ServiceType::RIS(ServiceType::RIS_e);
38 const ServiceType ServiceType::NONE(ServiceType::NONE_e);
39 const ServiceType ServiceType::PLUGIN(ServiceType::PLUGIN_e);
40
41 ServiceType::ServiceType(const std::string & strval_r)
42 : _type(parse(strval_r))
43 {}
44
45 ServiceType::Type ServiceType::parse(const std::string & strval_r)
46 {
48 if ( ! table().getValue( str::toLower( strval_r ), type ) )
49 {
50 ZYPP_THROW( RepoUnknownTypeException( "Unknown service type '" + strval_r + "'") );
51 }
52 return type;
53 }
54
55 const std::string & ServiceType::asString() const
56 {
57 return table().getName( _type );
58 }
59
60
61 } // ns repo
62} // ns zypp
63
64// vim: set ts=2 sts=2 sw=2 et ai:
thrown when it was impossible to determine this repo type.
std::string toLower(const std::string &s)
Return lowercase version of s.
Definition String.cc:180
Easy-to use interface to the ZYPP dependency resolver.
Service type enumeration.
Definition ServiceType.h:27
ServiceType::Type parse(const std::string &strval_r)
const std::string & asString() const
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition Exception.h:459