libzypp: zypp/ResKind.h Source File

libzypp 17.38.15

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-core/Globals.h>
19#include <zypp-core/base/String.h>
20#include <zypp/IdStringType.h>
21
23namespace zypp
24{
25
32 class ZYPP_API ResKind : public IdStringType<ResKind>
33 {
34 public:
37
38 static const ResKind nokind;
39
40 static const ResKind package;
41 static const ResKind patch;
42 static const ResKind pattern;
43 static const ResKind product;
44 static const ResKind srcpackage;
45 static const ResKind application;
47
53 static ResKind explicitBuiltin( const char * str_r );
55 static ResKind explicitBuiltin( const std::string & str_r )
56 { return explicitBuiltin( str_r.c_str() ); }
57
58 static ResKind explicitBuiltin( const IdString & str_r )
59 { return explicitBuiltin( str_r.c_str() ); }
60
65 static ResKind fromBuiltin( const std::string &str );
66
67 public:
69 ResKind() {}
70
72 explicit ResKind( sat::detail::IdType id_r ) : _str( str::toLower(IdString(id_r).c_str()) ) {}
73 explicit ResKind( const IdString & idstr_r ) : _str( str::toLower(idstr_r.c_str()) ) {}
74 explicit ResKind( const std::string & str_r ) : _str( str::toLower(str_r) ) {}
75 explicit ResKind( const char * cstr_r ) : _str( str::toLower(cstr_r) ) {}
76
77 public:
83 static std::string satIdent( const ResKind & refers_r, const std::string & name_r );
85 std::string satIdent( const std::string & name_r ) const
86 { return satIdent( *this, name_r ); }
87
88 private:
89 static int _doCompare( const char * lhs, const char * rhs )
90 {
91 if ( lhs == rhs ) return 0;
92 if ( lhs && rhs ) return ::strcasecmp( lhs, rhs );
93 return( lhs ? 1 : -1 );
94 }
95
96 private:
97 friend class IdStringType<ResKind>;
98 IdString _str;
99 };
100
102 inline std::ostream & dumpAsXmlOn( std::ostream & str, const ResKind & obj )
103 { return str << "<kind>" << obj << "</kind>"; }
104
106} // namespace zypp
108#endif // ZYPP_RESKIND_H
Globals.h
Provides API related macros.
IdStringType.h
String.h
zypp::IdStringType
Base class for creating IdString based types.
Definition IdStringType.h:95
zypp::IdStringType< ResKind >::IdStringType
IdStringType()=default
zypp::IdStringType< ResKind >::c_str
const char * c_str() const
Definition IdStringType.h:115
zypp::IdString
Access to the sat-pools string space.
Definition IdString.h:55
zypp::IdString::c_str
const char * c_str() const
Conversion to const char *.
Definition IdString.cc:51
zypp::ResKind
Resolvable kinds.
Definition ResKind.h:33
zypp::ResKind::srcpackage
static const ResKind srcpackage
Definition ResKind.h:44
zypp::ResKind::ResKind
ResKind(const IdString &idstr_r)
Definition ResKind.h:73
zypp::ResKind::application
static const ResKind application
Definition ResKind.h:45
zypp::ResKind::ResKind
ResKind(sat::detail::IdType id_r)
Ctor taking kind as string.
Definition ResKind.h:72
zypp::ResKind::pattern
static const ResKind pattern
Definition ResKind.h:42
zypp::ResKind::product
static const ResKind product
Definition ResKind.h:43
zypp::ResKind::ResKind
ResKind(const char *cstr_r)
Definition ResKind.h:75
zypp::ResKind::patch
static const ResKind patch
Definition ResKind.h:41
zypp::ResKind::explicitBuiltin
static ResKind explicitBuiltin(const char *str_r)
Return the builtin kind if str_r explicitly prefixed.
Definition ResKind.cc:46
zypp::ResKind::satIdent
std::string satIdent(const std::string &name_r) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition ResKind.h:85
zypp::ResKind::nokind
static const ResKind nokind
Value representing nokind ("").
Definition ResKind.h:38
zypp::ResKind::package
static const ResKind package
Definition ResKind.h:40
zypp::ResKind::satIdent
static std::string satIdent(const ResKind &refers_r, const std::string &name_r)
Return libsolv identifier for name.
Definition ResKind.cc:81
zypp::ResKind::_str
IdString _str
Definition ResKind.h:98
zypp::ResKind::ResKind
ResKind(const std::string &str_r)
Definition ResKind.h:74
zypp::ResKind::explicitBuiltin
static ResKind explicitBuiltin(const std::string &str_r)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition ResKind.h:55
zypp::ResKind::ResKind
ResKind()
Default ctor: nokind.
Definition ResKind.h:69
zypp::ResKind::_doCompare
static int _doCompare(const char *lhs, const char *rhs)
Definition ResKind.h:89
zypp::ResKind::explicitBuiltin
static ResKind explicitBuiltin(const IdString &str_r)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition ResKind.h:58
str
String related utilities and Regular expression matching.
zypp::sat::detail::IdType
int IdType
Generic Id type.
Definition PoolDefines.h:44
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2
zypp::dumpAsXmlOn
std::ostream & dumpAsXmlOn(std::ostream &str, const Repository &obj)
relates: Repository XML output
Definition Repository.cc:406
zypp::ZYPP_API
const Arch Arch_empty ZYPP_API
relates: Arch This is an empty Arch represented by an empty string.
Definition Arch.h:173