libzypp 17.31.23
ResKind.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#include <iostream>
13
14#include <zypp/base/String.h>
15
16#include <zypp/ResKind.h>
17#include <zypp/ResTraits.h>
18
19using std::endl;
20
22namespace zypp
23{
24
25 const ResKind ResKind::nokind;
26 const ResKind ResKind::package ( "package" );
27 const ResKind ResKind::patch ( "patch" );
28 const ResKind ResKind::pattern ( "pattern" );
29 const ResKind ResKind::product ( "product" );
30 const ResKind ResKind::srcpackage ( "srcpackage" );
31 const ResKind ResKind::application ( "application" );
32
33 template<>
35 template<>
37 template<>
39 template<>
41 template<>
43 template<>
45
46 ResKind ResKind::explicitBuiltin( const char * str_r )
47 {
48 if ( str_r && str_r[0] && str_r[1] && str_r[2] )
49 {
50 switch ( str_r[3] )
51 {
52 // NOTE: it needs to be assertd that the separating ':' is present
53 // if a known kind is retuirned. Dependent code relies on this!
54 #define OUTS(K,S) if ( !::strncmp( str_r, ResKind::K.c_str(), S ) && str_r[S] == ':' ) return ResKind::K
55 // ----v
56 case 'c': OUTS( patch, 5 ); break;
57 case 'd': OUTS( product, 7 ); break;
58 case 'k': OUTS( package, 7 ); break;
59 case 'l': OUTS( application, 11 );break;
60 case 'p': OUTS( srcpackage, 10 ); break;
61 case 't': OUTS( pattern, 7 ); break;
62 #undef OUTS
63 }
64 }
65 return nokind;
66 }
67
68 std::string ResKind::satIdent( const ResKind & refers_r, const std::string & name_r )
69 {
70 if ( ! refers_r || refers_r == package || refers_r == srcpackage )
71 return name_r;
72 return str::form( "%s:%s", refers_r.c_str(), name_r.c_str() );
73 }
74
76} // namespace zypp
#define OUTS(V)
const char * c_str() const
Definition: IdStringType.h:105
Resolvable kinds.
Definition: ResKind.h:33
static const ResKind srcpackage
Definition: ResKind.h:44
static const ResKind application
Definition: ResKind.h:45
static const ResKind pattern
Definition: ResKind.h:42
static const ResKind product
Definition: ResKind.h:43
static const ResKind patch
Definition: ResKind.h:41
static ResKind explicitBuiltin(const char *str_r)
Return the builtin kind if str_r explicitly prefixed.
Definition: ResKind.cc:46
static const ResKind nokind
Value representing nokind ("")
Definition: ResKind.h:38
static const ResKind package
Definition: ResKind.h:40
static std::string satIdent(const ResKind &refers_r, const std::string &name_r)
Return libsolv identifier for name.
Definition: ResKind.cc:68
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition: String.cc:36
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
ResTraits.
Definition: ResTraits.h:80
static const ResKind kind
Defined in ResKind.cc.
Definition: ResTraits.h:85