libzypp
12.16.5
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/base/SafeBool.h
"
18
#include "
zypp/APIConfig.h
"
19
20
#include "
zypp/sat/detail/PoolMember.h
"
21
22
#include "
zypp/IdString.h
"
23
#include "
zypp/Edition.h
"
24
#include "
zypp/Rel.h
"
25
#include "
zypp/ResTraits.h
"
26
27
#include "
zypp/CapMatch.h
"
28
30
namespace
zypp
31
{
32
33
class
Capability;
34
class
CapDetail;
35
class
Arch
;
36
37
typedef
std::tr1::unordered_set<Capability>
CapabilitySet
;
38
40
//
41
// CLASS NAME : Capability
42
//
61
class
Capability
:
protected
sat::detail::PoolMember
,
62
private
base::SafeBool
<Capability>
63
{
64
public
:
65
enum
CtorFlag
{
PARSED
,
UNPARSED
};
66
67
public
:
69
Capability
() :
_id
( sat::
detail
::
emptyId
) {}
70
72
explicit
Capability
(
sat::detail::IdType
id_r ) :
_id
( id_r ) {}
73
82
explicit
Capability
(
const
char
* str_r,
const
ResKind
& prefix_r =
ResKind
(),
CtorFlag
flag_r =
UNPARSED
);
84
explicit
Capability
(
const
std::string & str_r,
const
ResKind
& prefix_r =
ResKind
(),
CtorFlag
flag_r =
UNPARSED
);
86
Capability
(
const
Arch
& arch_r,
const
char
* str_r,
const
ResKind
& prefix_r =
ResKind
(),
CtorFlag
flag_r =
UNPARSED
);
88
Capability
(
const
Arch
& arch_r,
const
std::string & str_r,
const
ResKind
& prefix_r =
ResKind
(),
CtorFlag
flag_r =
UNPARSED
);
89
91
Capability
(
const
char
* str_r,
CtorFlag
flag_r,
const
ResKind
& prefix_r =
ResKind
() );
93
Capability
(
const
std::string & str_r,
CtorFlag
flag_r,
const
ResKind
& prefix_r =
ResKind
() );
95
Capability
(
const
Arch
& arch_r,
const
char
* str_r,
CtorFlag
flag_r,
const
ResKind
& prefix_r =
ResKind
() );
97
Capability
(
const
Arch
& arch_r,
const
std::string & str_r,
CtorFlag
flag_r,
const
ResKind
& prefix_r =
ResKind
() );
99
100
105
Capability
(
const
std::string & name_r,
const
std::string & op_r,
const
std::string & ed_r,
const
ResKind
& prefix_r =
ResKind
() );
107
Capability
(
const
std::string & name_r,
Rel
op_r,
const
std::string & ed_r,
const
ResKind
& prefix_r =
ResKind
() );
109
Capability
(
const
std::string & name_r,
Rel
op_r,
const
Edition
& ed_r,
const
ResKind
& prefix_r =
ResKind
() );
111
116
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
() );
118
Capability
(
const
std::string & arch_r,
const
std::string & name_r,
Rel
op_r,
const
std::string & ed_r,
const
ResKind
& prefix_r =
ResKind
() );
120
Capability
(
const
std::string & arch_r,
const
std::string & name_r,
Rel
op_r,
const
Edition
& ed_r,
const
ResKind
& prefix_r =
ResKind
() );
122
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
() );
124
Capability
(
const
Arch
& arch_r,
const
std::string & name_r,
Rel
op_r,
const
std::string & ed_r,
const
ResKind
& prefix_r =
ResKind
() );
126
Capability
(
const
Arch
& arch_r,
const
std::string & name_r,
Rel
op_r,
const
Edition
& ed_r,
const
ResKind
& prefix_r =
ResKind
() );
128
129
public
:
131
static
const
Capability
Null
;
132
134
static
const
Capability
Empty
;
135
136
public
:
137
#ifndef SWIG // Swig treats it as syntax error
138
139
using
base::SafeBool<Capability>::operator
bool_type
;
140
#endif
141
144
bool
empty
()
const
145
{
return
(
_id
==
sat::detail::emptyId
||
_id
==
sat::detail::noId
); }
146
147
public
:
149
const
char
*
c_str
()
const
;
150
152
std::string
asString
()
const
153
{
return
c_str
(); }
154
155
public
:
157
CapDetail
detail
()
const
;
158
159
public
:
170
static
CapMatch
matches
(
const
Capability
& lhs,
const
Capability
& rhs ) {
return
_doMatch
( lhs.
id
(), rhs.
id
() ); }
171
static
CapMatch
matches
(
const
Capability
& lhs,
const
IdString
& rhs ) {
return
_doMatch
( lhs.
id
(), rhs.
id
() ); }
172
static
CapMatch
matches
(
const
Capability
& lhs,
const
std::string & rhs ) {
return
_doMatch
( lhs.
id
(),
Capability
(rhs).id() ); }
173
static
CapMatch
matches
(
const
Capability
& lhs,
const
char
* rhs ) {
return
_doMatch
( lhs.
id
(),
Capability
(rhs).id() );}
174
175
static
CapMatch
matches
(
const
IdString
& lhs,
const
Capability
& rhs ) {
return
_doMatch
( lhs.
id
(), rhs.
id
() ); }
176
static
CapMatch
matches
(
const
IdString
& lhs,
const
IdString
& rhs ) {
return
_doMatch
( lhs.
id
(), rhs.
id
() ); }
177
static
CapMatch
matches
(
const
IdString
& lhs,
const
std::string & rhs ) {
return
_doMatch
( lhs.
id
(),
Capability
(rhs).id() ); }
178
static
CapMatch
matches
(
const
IdString
& lhs,
const
char
* rhs ) {
return
_doMatch
( lhs.
id
(),
Capability
(rhs).id() ); }
179
180
static
CapMatch
matches
(
const
std::string & lhs,
const
Capability
& rhs ) {
return
_doMatch
(
Capability
(lhs).
id
(), rhs.
id
() );}
181
static
CapMatch
matches
(
const
std::string & lhs,
const
IdString
& rhs ) {
return
_doMatch
(
Capability
(lhs).
id
(), rhs.
id
() ); }
182
static
CapMatch
matches
(
const
std::string & lhs,
const
std::string & rhs ) {
return
_doMatch
(
Capability
(lhs).
id
(),
Capability
(rhs).
id
() ); }
183
static
CapMatch
matches
(
const
std::string & lhs,
const
char
* rhs ) {
return
_doMatch
(
Capability
(lhs).
id
(),
Capability
(rhs).
id
() ); }
184
185
static
CapMatch
matches
(
const
char
* lhs,
const
Capability
& rhs ) {
return
_doMatch
(
Capability
(lhs).
id
(), rhs.
id
() );}
186
static
CapMatch
matches
(
const
char
* lhs,
const
IdString
& rhs ) {
return
_doMatch
(
Capability
(lhs).
id
(), rhs.
id
() ); }
187
static
CapMatch
matches
(
const
char
* lhs,
const
std::string & rhs ) {
return
_doMatch
(
Capability
(lhs).
id
(),
Capability
(rhs).
id
() ); }
188
static
CapMatch
matches
(
const
char
* lhs,
const
char
* rhs ) {
return
_doMatch
(
Capability
(lhs).
id
(),
Capability
(rhs).
id
() ); }
189
190
CapMatch
matches
(
const
Capability
& rhs )
const
{
return
_doMatch
(
id
(), rhs.
id
() ); }
191
CapMatch
matches
(
const
IdString
& rhs )
const
{
return
_doMatch
(
id
(), rhs.
id
() ); }
192
CapMatch
matches
(
const
std::string & rhs )
const
{
return
_doMatch
(
id
(),
Capability
(rhs).
id
() ); }
193
CapMatch
matches
(
const
char
* rhs )
const
{
return
_doMatch
(
id
(),
Capability
(rhs).
id
() ); }
195
198
struct
Matches
:
public
std::binary_function<Capability,Capability,CapMatch>
199
{
200
CapMatch
operator()
(
const
Capability
& lhs,
const
Capability
& rhs )
const
201
{
return
Capability::matches
( lhs, rhs ); }
202
};
203
204
public
:
210
static
bool
isInterestingFileSpec
(
const
IdString
& name_r ) {
return
isInterestingFileSpec
( name_r.
c_str
() ); }
211
static
bool
isInterestingFileSpec
(
const
std::string & name_r ) {
return
isInterestingFileSpec
( name_r.c_str() ); }
212
static
bool
isInterestingFileSpec
(
const
char
* name_r );
213
238
static
Capability
guessPackageSpec
(
const
std::string & str_r );
243
static
Capability
guessPackageSpec
(
const
std::string & str_r,
bool
& rewrote_r );
244
245
public
:
247
sat::detail::IdType
id
()
const
248
{
return
_id
; }
249
private
:
251
static
CapMatch
_doMatch
(
sat::detail::IdType
lhs,
sat::detail::IdType
rhs );
252
private
:
253
#ifndef SWIG // Swig treats it as syntax error
254
friend
base::SafeBool<Capability>::operator
bool_type
()
const
;
255
#endif
256
bool
boolTest
()
const
{
return
!
empty
(); }
257
private
:
258
sat::detail::IdType
_id
;
259
};
261
263
std::ostream &
operator<<
( std::ostream & str,
const
Capability
& obj );
264
266
std::ostream &
dumpOn
( std::ostream & str,
const
Capability
& obj );
267
269
inline
bool
operator==
(
const
Capability
& lhs,
const
Capability
& rhs )
270
{
return
lhs.
id
() == rhs.
id
(); }
271
273
inline
bool
operator!=
(
const
Capability
& lhs,
const
Capability
& rhs )
274
{
return
lhs.
id
() != rhs.
id
(); }
275
277
inline
bool
operator<
(
const
Capability
& lhs,
const
Capability
& rhs )
278
{
return
lhs.
id
() < rhs.
id
(); }
279
281
//
282
// CLASS NAME : CapDetail
283
//
297
class
CapDetail
:
protected
sat::detail::PoolMember
298
{
299
public
:
300
enum
Kind
301
{
302
NOCAP
= 0x00,
303
NAMED
= 0x01,
304
VERSIONED
= 0x02,
305
EXPRESSION
= 0x04
306
};
307
311
enum
CapRel
312
{
313
REL_NONE
= 0,
314
CAP_AND
= 16,
315
CAP_OR
= 17,
316
CAP_WITH
= 18,
317
CAP_NAMESPACE
= 19,
318
CAP_ARCH
= 20
319
};
320
321
public
:
322
CapDetail
()
323
:
_kind
(
NOCAP
),
_lhs
( 0 ),
_rhs
( 0 ),
_flag
( 0 ),
_archIfSimple
( 0 )
324
{}
325
explicit
CapDetail
(
const
Capability
& cap_r )
326
:
_kind
(
NOCAP
),
_lhs
( cap_r.id() ),
_rhs
( 0 ),
_flag
( 0 ),
_archIfSimple
( 0 )
327
{
_init
(); }
328
explicit
CapDetail
(
sat::detail::IdType
id_r )
329
:
_kind
(
NOCAP
),
_lhs
( id_r ),
_rhs
( 0 ),
_flag
( 0 ),
_archIfSimple
( 0 )
330
{
_init
(); }
331
332
public
:
333
Kind
kind
()
const
{
return
_kind
; }
334
bool
isNull
()
const
{
return
_kind
==
NOCAP
; }
335
bool
isNamed
()
const
{
return
_kind
==
NAMED
; }
336
bool
isVersioned
()
const
{
return
_kind
==
VERSIONED
; }
337
bool
isSimple
()
const
{
return
_kind
& (
NAMED
|
VERSIONED
); }
338
bool
isExpression
()
const
{
return
_kind
==
EXPRESSION
; }
339
342
bool
hasArch
()
const
{
return
_archIfSimple
; }
343
IdString
arch
()
const
{
return
_archIfSimple
?
IdString
(
_archIfSimple
) : IdString(); }
344
IdString
name
()
const
{
return
isSimple
() ?
IdString
(
_lhs
) :
IdString
(); }
345
Rel
op
()
const
{
return
isVersioned
() ?
Rel
(
_flag
) :
Rel::ANY
; }
346
Edition
ed
()
const
{
return
isVersioned
() ?
Edition
(
_rhs
) :
Edition
(); }
348
351
Capability
lhs
()
const
{
return
isExpression
() ?
Capability
(
_lhs
) :
Capability::Null
; }
352
CapRel
capRel
()
const
{
return
isExpression
() ?
CapRel
(
_flag
) :
REL_NONE
; }
353
Capability
rhs
()
const
{
return
isExpression
() ?
Capability
(
_rhs
) :
Capability::Null
; }
355
356
private
:
357
void
_init
();
358
private
:
359
Kind
_kind
;
360
sat::detail::IdType
_lhs
;
361
sat::detail::IdType
_rhs
;
362
unsigned
_flag
;
363
sat::detail::IdType
_archIfSimple
;
364
};
366
368
std::ostream &
operator<<
( std::ostream & str,
const
CapDetail
& obj );
369
371
std::ostream &
operator<<
( std::ostream & str,
CapDetail::Kind
obj );
372
374
std::ostream &
operator<<
( std::ostream & str,
CapDetail::CapRel
obj );
375
377
378
inline
CapDetail
Capability::detail
()
const
{
return
CapDetail
(
_id
); }
379
381
}
// namespace zypp
383
384
ZYPP_DEFINE_ID_HASHABLE
( ::
zypp::Capability
);
385
386
#endif // ZYPP_CAPABILITY_H
zypp
Capability.h
Generated by
1.8.2