libzypp
11.13.5
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
libzypp
Welcome to libzypp
Code Pitfalls - Frequently made mistakes
Code Snippets
Environment Variables
Testing for provided features.
Notes on revisions
Extending ZYpp: Plugins and Hooks
Services
Solver - Vendor protection
Writing and tunning testcases
Libzypp and threads
Todo List
Deprecated List
Modules
Namespaces
Classes
Files
File List
zypp
base
Algorithm.h
Collector.h
Counter.h
Debug.h
DefaultIntegral.h
DtorReset.h
Easy.h
Errno.h
Exception.cc
Exception.h
ExternalDataSource.cc
ExternalDataSource.h
Fd.cc
Fd.h
Flags.h
Function.h
Functional.h
Gettext.cc
Gettext.h
GzStream.cc
GzStream.h
InputStream.cc
InputStream.h
InterProcessMutex.cc
InterProcessMutex.h
IOStream.cc
IOStream.h
Iterator.h
LogControl.cc
LogControl.h
Logger.h
LogTools.h
Measure.cc
Measure.h
NonCopyable.h
ProfilingFormater.cc
ProfilingFormater.h
ProvideNumericId.h
PtrTypes.h
Random.cc
Random.h
ReferenceCounted.cc
ReferenceCounted.h
Regex.cc
Regex.h
SafeBool.h
SerialNumber.cc
SerialNumber.h
Signal.h
String.cc
String.h
StrMatcher.cc
StrMatcher.h
Sysconfig.cc
Sysconfig.h
Tr1hash.h
Unit.cc
Unit.h
UserRequestException.cc
UserRequestException.h
WatchFile.h
media
misc
parser
pool
repo
sat
solver
target
thread
ui
url
ws
zypp_detail
APIConfig.h
Arch.cc
Arch.h
AutoDispose.h
Bit.h
ByteCount.cc
ByteCount.h
Callback.h
Capabilities.cc
Capabilities.h
Capability.cc
Capability.h
CapMatch.cc
CapMatch.h
Changelog.cc
Changelog.h
CheckSum.cc
CheckSum.h
CountryCode.cc
CountryCode.h
Date.cc
Date.h
Dep.cc
Dep.h
Digest.cc
Digest.h
DiskUsage.cc
DiskUsage.h
DiskUsageCounter.cc
DiskUsageCounter.h
DownloadMode.cc
DownloadMode.h
Edition.cc
Edition.h
ExternalProgram.cc
ExternalProgram.h
Fetcher.cc
Fetcher.h
FileChecker.cc
FileChecker.h
Filter.h
Glob.cc
Glob.h
HistoryLog.cc
HistoryLog.h
HistoryLogData.cc
HistoryLogData.h
IdString.cc
IdString.h
IdStringType.h
InstanceId.cc
InstanceId.h
KeyContext.h
KeyRing.cc
KeyRing.h
KVMap.h
LanguageCode.cc
LanguageCode.h
Locale.cc
Locale.h
Locks.cc
Locks.h
ManagedFile.h
MediaProducts.cc
MediaProducts.h
MediaSetAccess.cc
MediaSetAccess.h
Misc.h
OnMediaLocation.cc
OnMediaLocation.h
Package.cc
Package.h
PackageKeyword.h
Patch.cc
Patch.h
PathInfo.cc
PathInfo.h
Pathname.cc
Pathname.h
Pattern.cc
Pattern.h
PluginFrame.cc
PluginFrame.h
PluginFrameException.cc
PluginFrameException.h
PluginScript.cc
PluginScript.h
PluginScriptException.cc
PluginScriptException.h
PoolItem.cc
PoolItem.h
PoolItemBest.cc
PoolItemBest.h
PoolQuery.cc
PoolQuery.h
PoolQueryResult.cc
PoolQueryResult.h
PoolQueryUtil.tcc
ProblemSolution.cc
ProblemSolution.h
ProblemTypes.h
Product.cc
Product.h
ProgressData.cc
ProgressData.h
ProvideFilePolicy.cc
ProvideFilePolicy.h
PublicKey.cc
PublicKey.h
Range.cc
Range.h
Rel.cc
Rel.h
RelCompare.h
RepoInfo.cc
RepoInfo.h
RepoManager.cc
RepoManager.h
Repository.cc
Repository.h
RepoStatus.cc
RepoStatus.h
ResFilters.h
ResKind.cc
ResKind.h
ResObject.cc
ResObject.h
ResObjects.h
Resolvable.cc
Resolvable.h
Resolver.cc
Resolver.h
ResolverProblem.cc
ResolverProblem.h
ResPool.cc
ResPool.h
ResPoolProxy.cc
ResPoolProxy.h
ResStatus.cc
ResStatus.h
ResTraits.h
ServiceInfo.cc
ServiceInfo.h
Signature.cc
Signature.h
SrcPackage.cc
SrcPackage.h
SysContent.cc
SysContent.h
Target.cc
Target.h
TmpPath.cc
TmpPath.h
TriBool.h
Url.cc
Url.h
Vendor.h
VendorAttr.cc
VendorAttr.h
VendorSupportOptions.cc
VendorSupportOptions.h
ZConfig.cc
ZConfig.h
ZYpp.cc
ZYpp.h
ZYppCallbacks.h
ZYppCommit.h
ZYppCommitPolicy.cc
ZYppCommitPolicy.h
ZYppCommitResult.cc
ZYppCommitResult.h
ZYppFactory.cc
ZYppFactory.h
File Members
StrMatcher.h
Go to the documentation of this file.
1
/*---------------------------------------------------------------------\
2
| ____ _ __ __ ___ |
3
| |__ / \ / / . \ . \ |
4
| / / \ V /| _/ _/ |
5
| / /__ | | | | | | |
6
| /_____||_| |_| |_| |
7
| |
8
\---------------------------------------------------------------------*/
12
#ifndef ZYPP_BASE_STRMATCHER_H
13
#define ZYPP_BASE_STRMATCHER_H
14
15
#include <iosfwd>
16
#include <string>
17
18
#include "
zypp/base/PtrTypes.h
"
19
#include "
zypp/base/SafeBool.h
"
20
#include "
zypp/base/Exception.h
"
21
23
namespace
zypp
24
{
33
class
Match
:
private
base::SafeBool
<Match>
34
{
35
private
:
36
static
const
int
_modemask
;
37
static
const
int
_flagmask
;
38
39
public
:
41
enum
Mode
42
{
43
NOTHING
,
44
STRING
,
45
STRINGSTART
,
46
STRINGEND
,
47
SUBSTRING
,
48
GLOB
,
49
REGEX
,
50
OTHER
51
};
52
60
static
const
Match
NOCASE
;
61
62
70
static
const
Match
NO_STORAGE_SOLVABLE
;
71
static
const
Match
SUB
;
72
static
const
Match
ARRAYSENTINEL
;
73
static
const
Match
DISABLED_REPOS
;
74
static
const
Match
COMPLETE_FILELIST
;
75
static
const
Match
SKIP_KIND
;
76
static
const
Match
FILES
;
77
static
const
Match
CHECKSUMS
;
78
79
80
public
:
82
Match
()
83
:
_val
( 0 )
84
{}
85
87
Match
(
Mode
val_r )
88
:
_val
(
modeval
( val_r ) )
89
{}
90
92
explicit
Match
(
int
val_r )
93
:
_val
( val_r )
94
{}
95
96
#ifndef SWIG // Swig treats it as syntax error
97
98
using
base::SafeBool<Match>::operator
bool_type
;
99
#endif
100
101
public
:
103
bool
test
(
const
Match
& rhs )
const
104
{
return
( (
flagval
() & rhs.
flagval
() ) == rhs.
flagval
() ) && ( !rhs.
modeval
() || rhs.
modeval
() ==
modeval
() ); }
105
107
bool
testAnyOf
(
const
Match
& rhs )
const
108
{
return
(
flagval
() & rhs.
flagval
() ) || ( rhs.
modeval
() && rhs.
modeval
() ==
modeval
() ); }
109
111
void
set
(
const
Match
& rhs )
112
{
113
if
( rhs.modeval() )
114
_val
= rhs._val |
flagval
();
// also set the rhs mode
115
else
116
_val
|= rhs._val;
// just set the flags
117
}
118
120
void
unset
(
const
Match
& rhs )
121
{
122
if
(
modeval
() == rhs.
modeval
() )
123
_val
=
flagval
() & ~rhs.
flagval
();
// also unset mode
124
else
125
_val
&= ~rhs.
flagval
();
// just unset falgs
126
}
127
129
void
turn
(
const
Match
& rhs,
bool
onoff )
130
{ onoff ?
set
( rhs ) :
unset
( rhs ); }
131
133
Match
&
operator|=
(
const
Match
& rhs )
134
{
set
( rhs );
return
*
this
; }
135
137
Match
&
operator-=
(
const
Match
& rhs )
138
{
unset
( rhs );
return
*
this
; }
139
140
public
:
142
Mode
mode
()
const
;
143
145
Match
flags
()
const
146
{
return
Match
(
flagval
() ); }
147
148
public
:
152
int
get
()
const
{
return
_val
; }
154
int
modeval
()
const
{
return
_val
&
_modemask
; }
156
int
flagval
()
const
{
return
_val
&
_flagmask
; }
158
159
public
:
163
bool
isMode
(
Mode
rhs )
const
164
{
return
modeval
() ==
modeval
( rhs ); }
166
bool
isModeString
()
const
167
{
return
isMode
(
STRING
); }
169
bool
isModeStringstart
()
const
170
{
return
isMode
(
STRINGSTART
); }
172
bool
isModeStringend
()
const
173
{
return
isMode
(
STRINGEND
); }
175
bool
isModeSubstring
()
const
176
{
return
isMode
(
SUBSTRING
); }
178
bool
isModeGlob
()
const
179
{
return
isMode
(
GLOB
); }
181
bool
isModeRegex
()
const
182
{
return
isMode
(
REGEX
); }
183
185
void
setMode
(
Mode
rhs )
186
{
_val
=
modeval
( rhs ) |
flagval
(); }
188
void
setModeString
()
189
{
setMode
(
STRING
); }
191
void
setModeStringstart
()
192
{
setMode
(
STRINGSTART
); }
194
void
setModeStringend
()
195
{
setMode
(
STRINGEND
); }
197
void
setModeSubstring
()
198
{
setMode
(
SUBSTRING
); }
200
void
setModeGlob
()
201
{
setMode
(
GLOB
); }
203
void
setModeRegex
()
204
{
setMode
(
REGEX
); }
206
208
std::string
asString
()
const
;
209
210
private
:
211
friend
base::SafeBool<Match>::operator
bool_type
()
const
;
212
bool
boolTest
()
const
{
return
_val
; }
213
215
static
int
modeval
(
Mode
mode_r );
216
217
private
:
218
int
_val
;
219
};
220
222
inline
bool
operator==
(
const
Match
& lhs,
const
Match
& rhs )
223
{
return
lhs.
get
() == rhs.
get
(); }
225
inline
bool
operator!=
(
const
Match
& lhs,
const
Match
& rhs )
226
{
return
lhs.
get
() != rhs.
get
(); }
227
229
inline
Match
operator|(
const
Match
& lhs,
const
Match
& rhs )
230
{
return
Match
(lhs) |= rhs; }
232
inline
Match
operator|(
Match::Mode
lhs,
Match::Mode
rhs )
233
{
return
Match
(lhs) |= rhs; }
234
236
inline
Match
operator-(
const
Match
& lhs,
const
Match
& rhs )
237
{
return
Match
(lhs) -= rhs; }
239
inline
Match
operator-(
Match::Mode
lhs,
Match::Mode
rhs )
240
{
return
Match
(lhs) -= rhs; }
241
243
std::ostream &
operator<<
( std::ostream & str,
Match::Mode
obj );
244
246
std::ostream &
operator<<
( std::ostream & str,
const
Match
& obj );
247
252
struct
MatchException
:
public
Exception
253
{
255
explicit
MatchException
(
const
std::string & msg_r ) :
Exception
( msg_r ) {}
256
};
257
262
struct
MatchUnknownModeException
:
public
MatchException
263
{
265
explicit
MatchUnknownModeException
(
const
std::string & msg_r ) :
MatchException
( msg_r ) {}
266
268
MatchUnknownModeException
(
const
Match
& mode_r,
const
std::string & msg_r = std::string() );
269
};
270
275
struct
MatchInvalidRegexException
:
public
MatchException
276
{
278
explicit
MatchInvalidRegexException
(
const
std::string & msg_r ) :
MatchException
( msg_r ) {}
279
281
MatchInvalidRegexException
(
const
std::string & regex_r,
int
regcomp_r );
282
};
283
302
class
StrMatcher
:
private
base::SafeBool
<StrMatcher>
303
{
304
friend
std::ostream &
operator<<
( std::ostream & str,
const
StrMatcher
& obj );
305
306
public
:
307
typedef
MatchException
Exception
;
308
309
public
:
311
class
Impl
;
312
313
public
:
315
StrMatcher
();
316
318
StrMatcher
(
const
std::string & search_r );
319
321
StrMatcher
(
const
std::string & search_r,
const
Match
& flags_r );
322
327
StrMatcher
(
const
std::string & search_r,
const
Match::Mode
& flags_r );
328
330
StrMatcher
(
const
std::string & search_r,
int
flags_r );
331
332
#ifndef SWIG // Swig treats it as syntax error
333
334
using
base::SafeBool<StrMatcher>::operator
bool_type
;
335
#endif
336
337
public
:
343
template
<
class
_Tp>
344
bool
operator()
(
const
_Tp & string_r )
const
345
{
return
doMatch
( string_r.c_str() ); }
347
bool
operator()
(
const
char
* string_r )
const
348
{
return
doMatch
( string_r ); }
349
350
public
:
352
const
std::string &
searchstring
()
const
;
353
355
void
setSearchstring
(
const
std::string & string_r );
356
358
void
setSearchstring
(
const
std::string & string_r,
const
Match
& flags_r );
359
361
const
Match
&
flags
()
const
;
362
364
void
setFlags
(
const
Match
& flags_r );
365
366
public
:
373
void
compile
()
const
;
374
376
bool
isCompiled
()
const
;
377
382
bool
doMatch
(
const
char
* string_r )
const
;
383
384
private
:
385
friend
base::SafeBool<StrMatcher>::operator
bool_type
()
const
;
386
bool
boolTest
()
const
387
{
return
!
searchstring
().empty(); }
388
389
private
:
391
RWCOW_pointer<Impl>
_pimpl
;
392
};
393
395
std::ostream &
operator<<
( std::ostream & str,
const
StrMatcher
& obj );
396
398
bool
operator==
(
const
StrMatcher
& lhs,
const
StrMatcher
& rhs );
399
401
inline
bool
operator!=
(
const
StrMatcher
& lhs,
const
StrMatcher
& rhs )
402
{
return
!( lhs == rhs ); }
403
405
bool
operator<
(
const
StrMatcher
& lhs,
const
StrMatcher
& rhs );
406
407
}
// namespace zypp
409
#endif // ZYPP_BASE_STRMATCHER_H
zypp
base
StrMatcher.h
Generated by
1.8.1