1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/ResKind.cc
14 #include "zypp/base/String.h"
16 #include "zypp/ResKind.h"
17 #include "zypp/ResTraits.h"
21 ///////////////////////////////////////////////////////////////////
23 { /////////////////////////////////////////////////////////////////
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" );
34 const ResKind ResTraits<Package> ::kind( ResKind::package );
36 const ResKind ResTraits<Patch> ::kind( ResKind::patch );
38 const ResKind ResTraits<Pattern> ::kind( ResKind::pattern );
40 const ResKind ResTraits<Product> ::kind( ResKind::product );
42 const ResKind ResTraits<SrcPackage> ::kind( ResKind::srcpackage );
44 const ResKind ResTraits<Application>::kind( ResKind::application );
46 ResKind ResKind::explicitBuiltin( const char * str_r )
48 if ( str_r && str_r[0] && str_r[1] && str_r[2] )
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
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;
68 std::string ResKind::satIdent( const ResKind & refers_r, const std::string & name_r )
70 if ( ! refers_r || refers_r == package || refers_r == srcpackage )
72 return str::form( "%s:%s", refers_r.c_str(), name_r.c_str() );
75 /////////////////////////////////////////////////////////////////
77 ///////////////////////////////////////////////////////////////////