#include <Regex.h>
|
| Regex () |
| ~Regex () |
| Regex (const wchar_t *_pattern, size_t _n, unsigned int _flags=0) __DCL_THROWS1(RegexException *) |
void | compile (const wchar_t *_pattern, size_t _n, unsigned int _flags=0) __DCL_THROWS1(RegexException *) |
bool | search (const wchar_t *_begin, const wchar_t *_end, unsigned int _flags=0) __DCL_THROWS1(RegexException *) |
bool | search (const wchar_t *_begin, const wchar_t *_end, MatchResults &_results, unsigned int _flags=0) __DCL_THROWS1(RegexException *) |
bool | match (const wchar_t *_begin, const wchar_t *_end, unsigned int _flags) __DCL_THROWS1(RegexException *) |
bool | match (const wchar_t *_begin, const wchar_t *_end, MatchResults &_results, unsigned int _flags=0) __DCL_THROWS1(RegexException *) |
| Regex (const String &_pattern, unsigned int _flags=0) __DCL_THROWS1(RegexException *) |
void | compile (const String &_pattern, unsigned int _flags=0) __DCL_THROWS1(RegexException *) |
bool | search (const String &_string, unsigned int _flags=0) __DCL_THROWS1(RegexException *) |
bool | search (const String &_string, MatchResults &_results, unsigned int _flags=0) __DCL_THROWS1(RegexException *) |
bool | match (const String &_string, unsigned int _flags=0) __DCL_THROWS1(RegexException *) |
bool | match (const String &_string, MatchResults &_results, unsigned int _flags=0) __DCL_THROWS1(RegexException *) |
String | replace (const String &_string, const String &_replacement, size_t _limit=(size_t) -1) __DCL_THROWS1(RegexException *) |
size_t | split (const wchar_t *_begin, const wchar_t *_end, StringArray &_results, size_t _limit=(size_t) -1) __DCL_THROWS1(RegexException *) |
size_t | split (const String &_string, StringArray &_results, size_t _limit=(size_t) -1) __DCL_THROWS1(RegexException *) |
Definition at line 31 of file Regex.h.
◆ CompileFlags
Enumerator |
---|
ICASE | |
NOSUBS | |
NEWLINE | |
Definition at line 34 of file Regex.h.
◆ MatchFlags
◆ Regex() [1/3]
◆ ~Regex()
Definition at line 77 of file Regex.cpp.
78{
79 if (__handle) {
81
82 }
83}
void __regex_destroy(regex_handle _handle)
◆ Regex() [2/3]
Regex::Regex |
( |
const wchar_t * | _pattern, |
|
|
size_t | _n, |
|
|
unsigned int | _flags = 0 ) |
Definition at line 90 of file Regex.cpp.
93{
96}
void compile(const wchar_t *_pattern, size_t _n, unsigned int _flags=0) __DCL_THROWS1(RegexException *)
◆ Regex() [3/3]
Regex::Regex |
( |
const String & | _pattern, |
|
|
unsigned int | _flags = 0 ) |
Definition at line 98 of file Regex.cpp.
100{
102 compile(_pattern.data(), _pattern.length(), _flags);
103}
◆ compile() [1/2]
void Regex::compile |
( |
const String & | _pattern, |
|
|
unsigned int | _flags = 0 ) |
|
inline |
Definition at line 134 of file Regex.h.
136{
137 compile(_pattern.data(), _pattern.length(), _flags);
138}
◆ compile() [2/2]
void Regex::compile |
( |
const wchar_t * | _pattern, |
|
|
size_t | _n, |
|
|
unsigned int | _flags = 0 ) |
Definition at line 105 of file Regex.cpp.
108{
109 if (!__handle) {
111 }
112
113 try {
115 }
116
117 catch (std::exception& e) {
118 throw(new RegexException(typeid(e).name(), e.what()));
119 }
120}
regex_handle __regex_create()
void __regex_compile(regex_handle _handle, const wchar_t *_pattern, size_t _n, unsigned int _flags)
◆ match() [1/4]
bool Regex::match |
( |
const String & | _string, |
|
|
MatchResults & | _results, |
|
|
unsigned int | _flags = 0 ) |
|
inline |
Definition at line 158 of file Regex.h.
160{
161 return match(_string.data(), _string.data() + _string.length(), _results, _flags);
162}
bool match(const wchar_t *_begin, const wchar_t *_end, unsigned int _flags) __DCL_THROWS1(RegexException *)
◆ match() [2/4]
bool Regex::match |
( |
const String & | _string, |
|
|
unsigned int | _flags = 0 ) |
|
inline |
Definition at line 152 of file Regex.h.
154{
155 return match(_string.data(), _string.data() + _string.length(), _flags);
156}
◆ match() [3/4]
bool Regex::match |
( |
const wchar_t * | _begin, |
|
|
const wchar_t * | _end, |
|
|
Regex::MatchResults & | _results, |
|
|
unsigned int | _flags = 0 ) |
Definition at line 180 of file Regex.cpp.
183{
185
186 try {
187 match_result* results =
NULL;
188 size_t n =
__regex_match(__handle, _begin, _end, &results, _flags);
190 _results.attach(results,
n);
191 return true;
192 }
193 }
194
195 catch (std::exception& e) {
196 throw(new RegexException(typeid(e).name(), e.what()));
197 }
198
199 return false;
200}
size_t __regex_match(regex_handle _handle, const wchar_t *_begin, const wchar_t *_end, match_result **_results, unsigned int _flags)
#define __DCL_ASSERT(expr)
void CharsetConvertException *size_t n
◆ match() [4/4]
bool Regex::match |
( |
const wchar_t * | _begin, |
|
|
const wchar_t * | _end, |
|
|
unsigned int | _flags ) |
Definition at line 162 of file Regex.cpp.
165{
167
169 try {
171 }
172
173 catch (std::exception& e) {
174 throw(new RegexException(typeid(e).name(), e.what()));
175 }
176
178}
◆ replace()
String Regex::replace |
( |
const String & | _string, |
|
|
const String & | _replacement, |
|
|
size_t | _limit = (size_t)-1 ) |
Definition at line 202 of file Regex.cpp.
207{
208 const wchar_t* _begin = _string.data();
209 const wchar_t* _end = _string.data() + _string.length();
211
213 while (_begin < _end && 0 < _limit &&
search(_begin, _end, results)) {
214 r.append(_begin, results[0].first);
215 r.append(_replacement);
216
217 _limit--;
218 _begin = results[0].second;
219 }
220
221 if (_begin < _end) {
222 r.append(_begin, _end);
223 }
224
226}
bool search(const wchar_t *_begin, const wchar_t *_end, unsigned int _flags=0) __DCL_THROWS1(RegexException *)
◆ search() [1/4]
bool Regex::search |
( |
const String & | _string, |
|
|
MatchResults & | _results, |
|
|
unsigned int | _flags = 0 ) |
|
inline |
Definition at line 146 of file Regex.h.
148{
149 return search(_string.data(), _string.data() + _string.length(), _results, _flags);
150}
◆ search() [2/4]
bool Regex::search |
( |
const String & | _string, |
|
|
unsigned int | _flags = 0 ) |
|
inline |
Definition at line 140 of file Regex.h.
142{
143 return search(_string.data(), _string.data() + _string.length(), _flags);
144}
◆ search() [3/4]
bool Regex::search |
( |
const wchar_t * | _begin, |
|
|
const wchar_t * | _end, |
|
|
Regex::MatchResults & | _results, |
|
|
unsigned int | _flags = 0 ) |
Definition at line 140 of file Regex.cpp.
143{
145
146 try {
147 match_result* results =
NULL;
150 _results.attach(results,
n);
151 return true;
152 }
153 }
154
155 catch (std::exception& e) {
156 throw(new RegexException(typeid(e).name(), e.what()));
157 }
158
159 return false;
160}
bool __regex_search(regex_handle _handle, const wchar_t *_begin, const wchar_t *_end, match_result **_results, unsigned int _flags)
◆ search() [4/4]
bool Regex::search |
( |
const wchar_t * | _begin, |
|
|
const wchar_t * | _end, |
|
|
unsigned int | _flags = 0 ) |
Definition at line 122 of file Regex.cpp.
125{
127
129 try {
131 }
132
133 catch (std::exception& e) {
134 throw(new RegexException(typeid(e).name(), e.what()));
135 }
136
138}
◆ split() [1/2]
size_t Regex::split |
( |
const String & | _string, |
|
|
StringArray & | _results, |
|
|
size_t | _limit = (size_t)-1 ) |
|
inline |
Definition at line 164 of file Regex.h.
169{
170 return split(_string.data(), _string.data() + _string.length(), _results, _limit);
171}
size_t split(const wchar_t *_begin, const wchar_t *_end, StringArray &_results, size_t _limit=(size_t) -1) __DCL_THROWS1(RegexException *)
◆ split() [2/2]
size_t Regex::split |
( |
const wchar_t * | _begin, |
|
|
const wchar_t * | _end, |
|
|
StringArray & | _results, |
|
|
size_t | _limit = (size_t)-1 ) |
Definition at line 228 of file Regex.cpp.
233{
236
238 while(_begin < _end && _limit > 0 &&
search(_begin, _end, results)) {
239 _results.add(String(_begin, results[0].first - _begin));
240
241 _limit--;
242 _begin = results[0].second;
243 }
244
245 if (_begin < _end) {
246 _results.add(String(_end, _end - _begin));
247 }
248
249 return _results.
size();
250}
◆ test() [1/2]
bool Regex::test |
( |
const char * | _regex, |
|
|
const char * | _string, |
|
|
bool | _icase = false ) |
|
static |
Definition at line 267 of file Regex.cpp.
272{
276 _regex, _regex + ByteString::length(_regex),
277 _string, _string + ByteString::length(_string),
278 _icase
279 ) != (size_t)-1;;
280}
#define __DCL_ASSERT_PARAM(expr)
◆ test() [2/2]
bool Regex::test |
( |
const wchar_t * | _regex, |
|
|
const wchar_t * | _string, |
|
|
bool | _icase = false ) |
|
static |
Definition at line 252 of file Regex.cpp.
257{
261 _regex, _regex + String::length(_regex),
262 _string, _string + String::length(_string),
263 _icase
264 ) != (size_t)-1;
265}
The documentation for this class was generated from the following files: