libzypp
17.14.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
Regex.h
Go to the documentation of this file.
1
/*---------------------------------------------------------------------\
2
| ____ _ __ __ ___ |
3
| |__ / \ / / . \ . \ |
4
| / / \ V /| _/ _/ |
5
| / /__ | | | | | | |
6
| /_____||_| |_| |_| |
7
| |
8
\---------------------------------------------------------------------*/
12
#ifndef ZYPP_BASE_REGEX_H
13
#define ZYPP_BASE_REGEX_H
14
15
#include <iosfwd>
16
#include <string>
17
#include <regex.h>
18
19
#include "
zypp/base/Exception.h
"
20
22
namespace
zypp
23
{
27
namespace
str
28
{
53
54
typedef
Exception
regex_error
;
55
56
class
smatch
;
57
class
regex
;
58
67
bool
regex_match
(
const
char
* s,
smatch
& matches,
const
regex
&
regex
);
68
70
inline
bool
regex_match
(
const
std::string & s,
smatch
& matches,
const
regex
&
regex
)
71
{
return
regex_match
( s.c_str(), matches, regex ); }
72
74
bool
regex_match
(
const
char
* s,
const
regex & regex );
75
77
inline
bool
regex_match
(
const
std::string & s,
const
regex
&
regex
)
78
{
return
regex_match
( s.c_str(), regex ); }
79
86
class
regex
87
{
88
public
:
89
90
enum
RegFlags
{
91
icase
= REG_ICASE,
92
nosubs
= REG_NOSUB,
93
match_extended
= REG_EXTENDED,
94
};
95
96
regex
();
97
regex
(
const
std::string& s,
int
flags =
match_extended
);
98
~regex
() throw();
99
100
regex
(const
regex
& rhs)
101
{
assign
(rhs.m_str, rhs.m_flags); }
102
103
regex
&
operator=
(
const
regex
& rhs)
104
{
assign
(rhs.
m_str
, rhs.
m_flags
);
return
*
this
; }
105
109
std::string
asString
()
const
110
{
return
m_str
; }
111
112
public
:
114
regex_t *
get
()
115
{
return
&
m_preg
; }
116
117
private
:
118
void
assign
(
const
std::string& s,
int
flags =
match_extended
);
119
120
private
:
121
friend
class
smatch
;
122
friend
bool
regex_match
(
const
char
* s,
str::smatch
& matches,
const
regex
&
regex
);
123
friend
bool
regex_match
(
const
char
* s,
const
regex
&
regex
);
124
std::string
m_str
;
125
int
m_flags
;
126
regex_t
m_preg
;
127
bool
m_valid
;
128
};
129
131
inline
std::ostream &
operator<<
( std::ostream & str,
const
regex
& obj )
132
{
return
str << obj.
asString
(); }
133
145
class
smatch
146
{
147
public
:
148
smatch
();
149
150
std::string
operator[]
(
unsigned
i)
const
;
151
152
unsigned
size
()
const
;
153
155
std::string::size_type
begin
(
unsigned
i )
const
;
156
158
std::string::size_type
end
(
unsigned
i )
const
;
159
161
std::string::size_type
size
(
unsigned
i )
const
;
162
163
std::string
match_str
;
164
regmatch_t
pmatch
[12];
165
};
166
167
}
// namespace str
169
}
// namespace zypp
171
#endif // ZYPP_BASE_STRING_H
zypp
base
Regex.h
Generated by
1.8.2