libzypp  13.10.6
ResKind.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_RESKIND_H
13 #define ZYPP_RESKIND_H
14 
15 #include <iosfwd>
16 #include <string>
17 
18 #include "zypp/APIConfig.h"
19 #include "zypp/base/String.h"
20 #include "zypp/IdStringType.h"
21 
23 namespace zypp
24 {
25 
27  //
28  // CLASS NAME : ResKind
29  //
35  class ResKind : public IdStringType<ResKind>
36  {
37  public:
41  static const ResKind nokind;
42 
43  static const ResKind package;
44  static const ResKind patch;
45  static const ResKind pattern;
46  static const ResKind product;
47  static const ResKind srcpackage;
49 
50  public:
52  ResKind() {}
53 
55  explicit ResKind( sat::detail::IdType id_r ) : _str( str::toLower(IdString(id_r).c_str()) ) {}
56  explicit ResKind( const IdString & idstr_r ) : _str( str::toLower(idstr_r.c_str()) ) {}
57  explicit ResKind( const std::string & str_r ) : _str( str::toLower(str_r) ) {}
58  explicit ResKind( const char * cstr_r ) : _str( str::toLower(cstr_r) ) {}
59 
60  public:
66  static std::string satIdent( const ResKind & refers_r, const std::string & name_r );
68  std::string satIdent( const std::string & name_r ) const
69  { return satIdent( *this, name_r ); }
70 
71  private:
72  static int _doCompare( const char * lhs, const char * rhs )
73  {
74  if ( lhs == rhs ) return 0;
75  if ( lhs && rhs ) return ::strcasecmp( lhs, rhs );
76  return( lhs ? 1 : -1 );
77  }
78 
79  private:
80  friend class IdStringType<ResKind>;
82  };
83 
85  inline std::ostream & dumpAsXmlOn( std::ostream & str, const ResKind & obj )
86  { return str << "<kind>" << obj << "</kind>"; }
87 
89 } // namespace zypp
91 #endif // ZYPP_RESKIND_H
int IdType
Generic Id type.
Definition: PoolMember.h:82
static const ResKind package
Definition: ResKind.h:43
static const ResKind srcpackage
Definition: ResKind.h:47
Access to the sat-pools string space.
Definition: IdString.h:39
Base class for creating IdString based types.
Definition: IdStringType.h:86
ResKind(const IdString &idstr_r)
Definition: ResKind.h:56
ResKind(sat::detail::IdType id_r)
Ctor taking kind as string.
Definition: ResKind.h:55
static std::string satIdent(const ResKind &refers_r, const std::string &name_r)
Return libsolv identifier for name.
Definition: ResKind.cc:43
Provides API related macros.
static const ResKind pattern
Definition: ResKind.h:45
std::string satIdent(const std::string &name_r) const
Definition: ResKind.h:68
std::ostream & dumpAsXmlOn(std::ostream &str, const ResKind &obj)
Definition: ResKind.h:85
ResKind()
Default ctor: nokind.
Definition: ResKind.h:52
std::string toLower(const std::string &s)
Return lowercase version of s.
Definition: String.cc:166
IdString _str
Definition: ResKind.h:81
const char * c_str() const
Definition: IdStringType.h:105
static int _doCompare(const char *lhs, const char *rhs)
Definition: ResKind.h:72
ResKind(const std::string &str_r)
Definition: ResKind.h:57
static const ResKind nokind
Value representing nokind (&quot;&quot;)
Definition: ResKind.h:41
static const ResKind product
Definition: ResKind.h:46
Resolvable kinds.
Definition: ResKind.h:35
static const ResKind patch
Definition: ResKind.h:44
ResKind(const char *cstr_r)
Definition: ResKind.h:58