libzypp 17.31.23
ResolverFocus.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
11#include <iostream>
12#include <zypp/base/Logger.h>
13#include <zypp/base/String.h>
14#include <zypp/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':
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
#define OUTS(V)
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
bool fromString(const std::string &val_r, ResolverFocus &ret_r)
ResolverFocus
The resolver's general attitude.
Definition: ResolverFocus.h:22
@ Update
Focus on updating requested packages and their dependencies as much as possible.
@ Default
Request the standard behavior (as defined in zypp.conf or 'Job')
@ Installed
Focus on applying as little changes to the installed packages as needed.
@ Job
Focus on installing the best version of the requested packages.
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
Definition: String.h:212
#define WAR
Definition: Logger.h:97