libzypp
17.14.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
Capability.h
Go to the documentation of this file.
1
/*---------------------------------------------------------------------\
2
| ____ _ __ __ ___ |
3
| |__ / \ / / . \ . \ |
4
| / / \ V /| _/ _/ |
5
| / /__ | | | | | | |
6
| /_____||_| |_| |_| |
7
| |
8
\---------------------------------------------------------------------*/
12
#ifndef ZYPP_CAPABILITY_H
13
#define ZYPP_CAPABILITY_H
14
15
#include <iosfwd>
16
17
#include "
zypp/APIConfig.h
"
18
#include "
zypp/sat/detail/PoolMember.h
"
19
20
#include "
zypp/IdString.h
"
21
#include "
zypp/Edition.h
"
22
#include "
zypp/Rel.h
"
23
#include "
zypp/ResTraits.h
"
24
#include "
zypp/ResolverNamespace.h
"
25
#include "
zypp/CapMatch.h
"
26
28
namespace
zypp
29
{
30
31
class
Capability;
32
class
CapDetail;
33
class
Arch
;
34
35
typedef
std::unordered_set<Capability>
CapabilitySet
;
36
38
//
39
// CLASS NAME : Capability
40
//
59
class
Capability
:
protected
sat::detail::PoolMember
60
{
61
public
:
62
enum
CtorFlag
{
PARSED
,
UNPARSED
};
63
64
public
:
66
Capability
() :
_id
( sat::
detail
::
emptyId
) {}
67
69
explicit
Capability
(
sat::detail::IdType
id_r ) :
_id
( id_r ) {}
70
79
explicit
Capability
(
const
char
* str_r,
const
ResKind
& prefix_r =
ResKind
(),
CtorFlag
flag_r =
UNPARSED
);
81
explicit
Capability
(
const
std::string & str_r,
const
ResKind
& prefix_r =
ResKind
(),
CtorFlag
flag_r =
UNPARSED
);
83
Capability
(
const
Arch
& arch_r,
const
char
* str_r,
const
ResKind
& prefix_r =
ResKind
(),
CtorFlag
flag_r =
UNPARSED
);
85
Capability
(
const
Arch
& arch_r,
const
std::string & str_r,
const
ResKind
& prefix_r =
ResKind
(),
CtorFlag
flag_r =
UNPARSED
);
86
88
Capability
(
const
char
* str_r,
CtorFlag
flag_r,
const
ResKind
& prefix_r =
ResKind
() );
90
Capability
(
const
std::string & str_r,
CtorFlag
flag_r,
const
ResKind
& prefix_r =
ResKind
() );
92
Capability
(
const
Arch
& arch_r,
const
char
* str_r,
CtorFlag
flag_r,
const
ResKind
& prefix_r =
ResKind
() );
94
Capability
(
const
Arch
& arch_r,
const
std::string & str_r,
CtorFlag
flag_r,
const
ResKind
& prefix_r =
ResKind
() );
96
97
102
Capability
(
const
std::string & name_r,
const
std::string & op_r,
const
std::string & ed_r,
const
ResKind
& prefix_r =
ResKind
() );
104
Capability
(
const
std::string & name_r,
Rel
op_r,
const
std::string & ed_r,
const
ResKind
& prefix_r =
ResKind
() );
106
Capability
(
const
std::string & name_r,
Rel
op_r,
const
Edition
& ed_r,
const
ResKind
& prefix_r =
ResKind
() );
108
113
Capability
(
const
std::string & arch_r,
const
std::string & name_r,
const
std::string & op_r,
const
std::string & ed_r,
const
ResKind
& prefix_r =
ResKind
() );
115
Capability
(
const
std::string & arch_r,
const
std::string & name_r,
Rel
op_r,
const
std::string & ed_r,
const
ResKind
& prefix_r =
ResKind
() );
117
Capability
(
const
std::string & arch_r,
const
std::string & name_r,
Rel
op_r,
const
Edition
& ed_r,
const
ResKind
& prefix_r =
ResKind
() );
119
Capability
(
const
Arch
& arch_r,
const
std::string & name_r,
const
std::string & op_r,
const
std::string & ed_r,
const
ResKind
& prefix_r =
ResKind
() );
121
Capability
(
const
Arch
& arch_r,
const
std::string & name_r,
Rel
op_r,
const
std::string & ed_r,
const
ResKind
& prefix_r =
ResKind
() );
123
Capability
(
const
Arch
& arch_r,
const
std::string & name_r,
Rel
op_r,
const
Edition
& ed_r,
const
ResKind
& prefix_r =
ResKind
() );
125
131
Capability
(
ResolverNamespace
namespace_r,
IdString
value_r =
IdString::Null
);
132
Capability
(
ResolverNamespace
namespace_r,
const
char
* value_r ) :
Capability
( namespace_r,
IdString
(value_r) ) {}
133
Capability
(
ResolverNamespace
namespace_r,
const
std::string & value_r ) :
Capability
( namespace_r,
IdString
(value_r) ) {}
135
public
:
137
static
const
Capability
Null
;
138
140
static
const
Capability
Empty
;
141
142
public
:
144
explicit
operator
bool
()
const
145
{
return
!
empty
(); }
146
150
bool
empty
()
const
151
{
return
(
_id
==
sat::detail::emptyId
||
_id
==
sat::detail::noId
); }
152
153
public
:
155
const
char
*
c_str
()
const
;
156
158
std::string
asString
()
const
159
{
return
c_str
(); }
160
161
public
:
163
CapDetail
detail
()
const
;
164
165
public
:
176
static
CapMatch
matches
(
const
Capability
& lhs,
const
Capability
& rhs ) {
return
_doMatch
( lhs.
id
(), rhs.
id
() ); }
177
static
CapMatch
matches
(
const
Capability
& lhs,
const
IdString
& rhs ) {
return
_doMatch
( lhs.
id
(), rhs.
id
() ); }
178
static
CapMatch
matches
(
const
Capability
& lhs,
const
std::string & rhs ) {
return
_doMatch
( lhs.
id
(),
Capability
(rhs).id() ); }
179
static
CapMatch
matches
(
const
Capability
& lhs,
const
char
* rhs ) {
return
_doMatch
( lhs.
id
(),
Capability
(rhs).id() );}
180
181
static
CapMatch
matches
(
const
IdString
& lhs,
const
Capability
& rhs ) {
return
_doMatch
( lhs.
id
(), rhs.
id
() ); }
182
static
CapMatch
matches
(
const
IdString
& lhs,
const
IdString
& rhs ) {
return
_doMatch
( lhs.
id
(), rhs.
id
() ); }
183
static
CapMatch
matches
(
const
IdString
& lhs,
const
std::string & rhs ) {
return
_doMatch
( lhs.
id
(),
Capability
(rhs).id() ); }
184
static
CapMatch
matches
(
const
IdString
& lhs,
const
char
* rhs ) {
return
_doMatch
( lhs.
id
(),
Capability
(rhs).id() ); }
185
186
static
CapMatch
matches
(
const
std::string & lhs,
const
Capability
& rhs ) {
return
_doMatch
(
Capability
(lhs).
id
(), rhs.
id
() );}
187
static
CapMatch
matches
(
const
std::string & lhs,
const
IdString
& rhs ) {
return
_doMatch
(
Capability
(lhs).
id
(), rhs.
id
() ); }
188
static
CapMatch
matches
(
const
std::string & lhs,
const
std::string & rhs ) {
return
_doMatch
(
Capability
(lhs).
id
(),
Capability
(rhs).
id
() ); }
189
static
CapMatch
matches
(
const
std::string & lhs,
const
char
* rhs ) {
return
_doMatch
(
Capability
(lhs).
id
(),
Capability
(rhs).
id
() ); }
190
191
static
CapMatch
matches
(
const
char
* lhs,
const
Capability
& rhs ) {
return
_doMatch
(
Capability
(lhs).
id
(), rhs.
id
() );}
192
static
CapMatch
matches
(
const
char
* lhs,
const
IdString
& rhs ) {
return
_doMatch
(
Capability
(lhs).
id
(), rhs.
id
() ); }
193
static
CapMatch
matches
(
const
char
* lhs,
const
std::string & rhs ) {
return
_doMatch
(
Capability
(lhs).
id
(),
Capability
(rhs).
id
() ); }
194
static
CapMatch
matches
(
const
char
* lhs,
const
char
* rhs ) {
return
_doMatch
(
Capability
(lhs).
id
(),
Capability
(rhs).
id
() ); }
195
196
CapMatch
matches
(
const
Capability
& rhs )
const
{
return
_doMatch
(
id
(), rhs.
id
() ); }
197
CapMatch
matches
(
const
IdString
& rhs )
const
{
return
_doMatch
(
id
(), rhs.
id
() ); }
198
CapMatch
matches
(
const
std::string & rhs )
const
{
return
_doMatch
(
id
(),
Capability
(rhs).
id
() ); }
199
CapMatch
matches
(
const
char
* rhs )
const
{
return
_doMatch
(
id
(),
Capability
(rhs).
id
() ); }
201
204
struct
Matches
:
public
std::binary_function<Capability,Capability,CapMatch>
205
{
206
CapMatch
operator()
(
const
Capability
& lhs,
const
Capability
& rhs )
const
207
{
return
Capability::matches
( lhs, rhs ); }
208
};
209
210
public
:
216
static
bool
isInterestingFileSpec
(
const
IdString
& name_r ) {
return
isInterestingFileSpec
( name_r.
c_str
() ); }
217
static
bool
isInterestingFileSpec
(
const
std::string & name_r ) {
return
isInterestingFileSpec
( name_r.c_str() ); }
218
static
bool
isInterestingFileSpec
(
const
char
* name_r );
219
244
static
Capability
guessPackageSpec
(
const
std::string & str_r );
249
static
Capability
guessPackageSpec
(
const
std::string & str_r,
bool
& rewrote_r );
250
251
public
:
253
sat::detail::IdType
id
()
const
254
{
return
_id
; }
255
private
:
257
static
CapMatch
_doMatch
(
sat::detail::IdType
lhs,
sat::detail::IdType
rhs );
258
private
:
259
sat::detail::IdType
_id
;
260
};
262
264
std::ostream &
operator<<
( std::ostream & str,
const
Capability
& obj );
265
267
std::ostream &
dumpOn
( std::ostream & str,
const
Capability
& obj );
268
270
inline
bool
operator==
(
const
Capability
& lhs,
const
Capability
& rhs )
271
{
return
lhs.
id
() == rhs.
id
(); }
272
274
inline
bool
operator!=
(
const
Capability
& lhs,
const
Capability
& rhs )
275
{
return
lhs.
id
() != rhs.
id
(); }
276
278
inline
bool
operator<
(
const
Capability
& lhs,
const
Capability
& rhs )
279
{
return
lhs.
id
() < rhs.
id
(); }
280
282
//
283
// CLASS NAME : CapDetail
284
//
298
class
CapDetail
:
protected
sat::detail::PoolMember
299
{
300
public
:
301
enum
Kind
302
{
303
NOCAP
= 0x00,
304
NAMED
= 0x01,
305
VERSIONED
= 0x02,
306
EXPRESSION
= 0x04
307
};
308
312
enum
CapRel
313
{
314
REL_NONE
= 0,
315
CAP_AND
= 16,
316
CAP_OR
= 17,
317
CAP_WITH
= 18,
318
CAP_NAMESPACE
= 19,
319
CAP_ARCH
= 20
320
};
321
322
public
:
323
CapDetail
()
324
:
_kind
(
NOCAP
),
_lhs
( 0 ),
_rhs
( 0 ),
_flag
( 0 ),
_archIfSimple
( 0 )
325
{}
326
explicit
CapDetail
(
const
Capability
& cap_r )
327
:
_kind
(
NOCAP
),
_lhs
( cap_r.id() ),
_rhs
( 0 ),
_flag
( 0 ),
_archIfSimple
( 0 )
328
{
_init
(); }
329
explicit
CapDetail
(
sat::detail::IdType
id_r )
330
:
_kind
(
NOCAP
),
_lhs
( id_r ),
_rhs
( 0 ),
_flag
( 0 ),
_archIfSimple
( 0 )
331
{
_init
(); }
332
333
public
:
334
Kind
kind
()
const
{
return
_kind
; }
335
bool
isNull
()
const
{
return
_kind
==
NOCAP
; }
336
bool
isNamed
()
const
{
return
_kind
==
NAMED
; }
337
bool
isVersioned
()
const
{
return
_kind
==
VERSIONED
; }
338
bool
isSimple
()
const
{
return
_kind
& (
NAMED
|
VERSIONED
); }
339
bool
isExpression
()
const
{
return
_kind
==
EXPRESSION
; }
340
343
bool
hasArch
()
const
{
return
_archIfSimple
; }
344
IdString
arch
()
const
{
return
_archIfSimple
?
IdString
(
_archIfSimple
) : IdString(); }
345
IdString
name
()
const
{
return
isSimple
() ?
IdString
(
_lhs
) :
IdString
(); }
346
Rel
op
()
const
{
return
isVersioned
() ?
Rel
(
_flag
) :
Rel::ANY
; }
347
Edition
ed
()
const
{
return
isVersioned
() ?
Edition
(
_rhs
) :
Edition
(); }
349
352
Capability
lhs
()
const
{
return
isExpression
() ?
Capability
(
_lhs
) :
Capability::Null
; }
353
CapRel
capRel
()
const
{
return
isExpression
() ?
CapRel
(
_flag
) :
REL_NONE
; }
354
Capability
rhs
()
const
{
return
isExpression
() ?
Capability
(
_rhs
) :
Capability::Null
; }
356
357
private
:
358
void
_init
();
359
private
:
360
Kind
_kind
;
361
sat::detail::IdType
_lhs
;
362
sat::detail::IdType
_rhs
;
363
unsigned
_flag
;
364
sat::detail::IdType
_archIfSimple
;
365
};
367
369
std::ostream &
operator<<
( std::ostream & str,
const
CapDetail
& obj );
370
372
std::ostream &
operator<<
( std::ostream & str,
CapDetail::Kind
obj );
373
375
std::ostream &
operator<<
( std::ostream & str,
CapDetail::CapRel
obj );
376
378
379
inline
CapDetail
Capability::detail
()
const
{
return
CapDetail
(
_id
); }
380
382
}
// namespace zypp
384
385
ZYPP_DEFINE_ID_HASHABLE
( ::
zypp::Capability
);
386
387
#endif // ZYPP_CAPABILITY_H
zypp
Capability.h
Generated by
1.8.2