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
Regex.cc
Go to the documentation of this file.
1
/*---------------------------------------------------------------------\
2
| ____ _ __ __ ___ |
3
| |__ / \ / / . \ . \ |
4
| / / \ V /| _/ _/ |
5
| / /__ | | | | | | |
6
| /_____||_| |_| |_| |
7
| |
8
\---------------------------------------------------------------------*/
12
#include <cstdio>
13
#include <cstdarg>
14
15
#include <iostream>
16
17
#include "
zypp/base/Regex.h
"
18
19
using namespace
zypp;
20
using namespace
zypp::str;
21
22
regex::regex()
23
: m_flags(match_extended)
24
, m_valid(false)
25
{
26
27
}
28
29
void
regex::assign
(
const
std::string& str,
int
flags)
30
{
31
m_valid
=
true
;
32
m_str
= str;
33
m_flags
= flags;
34
int
err;
35
char
errbuff[100];
36
if
(!(flags &
normal
)) {
37
flags |=
match_extended
;
38
flags &= ~(
normal
);
39
}
40
41
if
((err = regcomp(&
m_preg
, str.c_str(), flags))) {
42
m_valid
=
false
;
43
regerror(err, &
m_preg
, errbuff,
sizeof
(errbuff));
44
ZYPP_THROW
(
regex_error
(std::string(errbuff)));
45
}
46
}
47
48
regex::regex
(
const
std::string& str,
int
flags)
49
{
50
assign
(str, flags);
51
}
52
53
regex::~regex
() throw()
54
{
55
if
(
m_valid
)
56
regfree(&
m_preg
);
57
}
58
59
bool
zypp::str::regex_match
(
const
char
* s,
smatch
& matches,
const
regex
&
regex
)
60
{
61
bool
r = s && regex.
m_valid
&& !regexec(®ex.
m_preg
, s, 12, &matches.
pmatch
[0], 0);
62
if
(r)
63
matches.
match_str
= s;
64
return
r;
65
}
66
67
bool
zypp::str::regex_match
(
const
char
* s,
const
regex& regex)
68
{
69
return
s && !regexec(®ex.
m_preg
, s, 0, NULL, 0);
70
}
71
72
smatch::smatch
()
73
{
74
memset(&
pmatch
, -1,
sizeof
(
pmatch
));
75
}
76
77
std::string
smatch::operator[]
(
unsigned
i)
const
78
{
79
if
( i <
sizeof
(
pmatch
)/
sizeof
(*
pmatch
) &&
pmatch
[i].rm_so != -1 )
80
return
match_str
.substr(
pmatch
[i].rm_so,
pmatch
[i].rm_eo-
pmatch
[i].rm_so );
81
82
return
std::string();
83
}
84
85
86
unsigned
smatch::size
()
const
87
{
88
unsigned
matches = unsigned(-1);
89
// Get highest (pmatch[i].rm_so != -1). Just looking for the 1st
90
// (pmatch[i].rm_so == -1) is wrong as optional mayches "()?"
91
// may be embeded.
92
for
(
unsigned
i = 0; i <
sizeof
(
pmatch
)/
sizeof
(*
pmatch
); ++i )
93
{
94
if
(
pmatch
[i].rm_so != -1 )
95
matches = i;
96
}
97
return
++matches;
98
}
zypp
base
Regex.cc
Generated by
1.8.1