libzypp: zypp/ResolverFocus.cc Source File

libzypp 17.38.10

ResolverFocus.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
11#include <iostream>
12#include <zypp-core/base/Logger.h>
13#include <zypp-core/base/String.h>
14#include <zypp-core/base/Exception.h>
15#include <zypp/ResolverFocus.h>
16
17using std::endl;
18
20namespace zypp
21{
22 std::string asString( const ResolverFocus & val_r )
23 {
24 switch ( val_r )
25 {
26#define OUTS(V) case ResolverFocus::V: return #V; break
27 OUTS( Default );
28 OUTS( Job );
29 OUTS( Installed );
30 OUTS( Update );
31#undef OUTS
32 }
33 // Oops!
34 std::string ret { str::Str() << "ResolverFocus(" << static_cast<int>(val_r) << ")" };
35 WAR << "asString: dubious " << ret << endl;
36 return ret;
37 }
38
39 bool fromString( const std::string & val_r, ResolverFocus & ret_r )
40 {
41 switch ( val_r[0] )
42 {
43#define OUTS(V) if ( ::strcasecmp( val_r.c_str(), #V ) == 0 ) { ret_r = ResolverFocus::V; return true; }
44 case 'D':
45 case 'd':
46 OUTS( Default );
47 break;
48
49 case 'J':
50 case 'j':
51 OUTS( Job );
52 break;
53
54 case 'I':
55 case 'i':
56 OUTS( Installed );
57 break;
58
59 case 'U':
60 case 'u':
61 OUTS( Update );
62 break;
63
64 case '\0':
65 ret_r = ResolverFocus::Default;
66 return true;
67 break;
68#undef OUTS
69 }
70 // Oops!
71 WAR << "fromString: unknown ResolverFocus '" << val_r << "'" << endl;
72 return false;
73 }
74} // namespace zypp
OUTS
#define OUTS(VAL)
Exception.h
Logger.h
WAR
#define WAR
Definition Logger.h:104
ResolverFocus.h
String.h
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2
zypp::ResolverFocus
ResolverFocus
The resolver's general attitude.
Definition ResolverFocus.h:24
zypp::ResolverFocus::Update
@ Update
Focus on updating requested packages and their dependencies as much as possible.
Definition ResolverFocus.h:28
zypp::ResolverFocus::Default
@ Default
Request the standard behavior (as defined in zypp.conf or 'Job').
Definition ResolverFocus.h:25
zypp::ResolverFocus::Installed
@ Installed
Focus on applying as little changes to the installed packages as needed.
Definition ResolverFocus.h:27
zypp::ResolverFocus::Job
@ Job
Focus on installing the best version of the requested packages.
Definition ResolverFocus.h:26
zypp::fromString
bool fromString(const std::string &val_r, ResolverFocus &ret_r)
relates: ResolverFocus Conversion from string (enumerator name, case insensitive, empty string is Def...
Definition ResolverFocus.cc:39
zypp::asString
std::string asString(const Patch::Category &obj)
relates: Patch::Category string representation.
Definition Patch.cc:122
zypp::str::Str
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
Definition String.h:213