#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 75 of file Regex.cpp.
76{
77 if (__handle) {
79
80 }
81}
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 88 of file Regex.cpp.
91{
94}
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 96 of file Regex.cpp.
98{
100 compile(_pattern.data(), _pattern.length(), _flags);
101}
◆ compile() [1/2]
| void Regex::compile |
( |
const String & | _pattern, |
|
|
unsigned int | _flags = 0 ) |
|
inline |
Definition at line 138 of file Regex.h.
142{
143 compile(_pattern.data(), _pattern.length(), _flags);
144}
◆ compile() [2/2]
| void Regex::compile |
( |
const wchar_t * | _pattern, |
|
|
size_t | _n, |
|
|
unsigned int | _flags = 0 ) |
Definition at line 103 of file Regex.cpp.
106{
107 if (!__handle) {
109 }
110
111 try {
113 }
114
115 catch (std::exception& e) {
116 throw(new RegexException(typeid(e).name(), e.what()));
117 }
118}
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 179 of file Regex.h.
183{
185 _string.data(), _string.data() + _string.length(),
186 _results, _flags
187 );
188}
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 168 of file Regex.h.
172{
174 _string.data(), _string.data() + _string.length(),
175 _flags
176 );
177}
◆ match() [3/4]
| bool Regex::match |
( |
const wchar_t * | _begin, |
|
|
const wchar_t * | _end, |
|
|
Regex::MatchResults & | _results, |
|
|
unsigned int | _flags = 0 ) |
Definition at line 178 of file Regex.cpp.
181{
183
184 try {
185 match_result* results =
NULL;
186 size_t n =
__regex_match(__handle, _begin, _end, &results, _flags);
187 if (n) {
188 _results.attach(results, n);
189 return true;
190 }
191 }
192
193 catch (std::exception& e) {
194 throw(new RegexException(typeid(e).name(), e.what()));
195 }
196
197 return false;
198}
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)
◆ match() [4/4]
| bool Regex::match |
( |
const wchar_t * | _begin, |
|
|
const wchar_t * | _end, |
|
|
unsigned int | _flags ) |
Definition at line 160 of file Regex.cpp.
163{
165
167 try {
169 }
170
171 catch (std::exception& e) {
172 throw(new RegexException(typeid(e).name(), e.what()));
173 }
174
176}
◆ replace()
| String Regex::replace |
( |
const String & | _string, |
|
|
const String & | _replacement, |
|
|
size_t | _limit = (size_t)-1 ) |
Definition at line 200 of file Regex.cpp.
205{
206 const wchar_t* _begin = _string.data();
207 const wchar_t* _end = _string.data() + _string.length();
209
211 while (_begin < _end && 0 < _limit &&
search(_begin, _end, results)) {
212 r.append(_begin, results[0].first);
213 r.append(_replacement);
214
215 _limit--;
216 _begin = results[0].second;
217 }
218
219 if (_begin < _end) {
220 r.append(_begin, _end);
221 }
222
224}
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 157 of file Regex.h.
161{
163 _string.data(), _string.data() + _string.length(),
164 _results, _flags
165 );
166}
◆ search() [2/4]
| bool Regex::search |
( |
const String & | _string, |
|
|
unsigned int | _flags = 0 ) |
|
inline |
Definition at line 146 of file Regex.h.
150{
152 _string.data(), _string.data() + _string.length(),
153 _flags
154 );
155}
◆ search() [3/4]
| bool Regex::search |
( |
const wchar_t * | _begin, |
|
|
const wchar_t * | _end, |
|
|
Regex::MatchResults & | _results, |
|
|
unsigned int | _flags = 0 ) |
Definition at line 138 of file Regex.cpp.
141{
143
144 try {
145 match_result* results =
NULL;
146 size_t n =
__regex_search(__handle, _begin, _end, &results, _flags);
147 if (n) {
148 _results.attach(results, n);
149 return true;
150 }
151 }
152
153 catch (std::exception& e) {
154 throw(new RegexException(typeid(e).name(), e.what()));
155 }
156
157 return false;
158}
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 120 of file Regex.cpp.
123{
125
127 try {
129 }
130
131 catch (std::exception& e) {
132 throw(new RegexException(typeid(e).name(), e.what()));
133 }
134
136}
◆ split() [1/2]
| size_t Regex::split |
( |
const String & | _string, |
|
|
StringArray & | _results, |
|
|
size_t | _limit = (size_t)-1 ) |
|
inline |
Definition at line 190 of file Regex.h.
195{
197 _string.data(), _string.data() + _string.length(),
198 _results, _limit
199 );
200}
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 226 of file Regex.cpp.
231{
234
236 while(_begin < _end && _limit > 0 &&
search(_begin, _end, results)) {
237 _results.add(String(_begin, results[0].first - _begin));
238
239 _limit--;
240 _begin = results[0].second;
241 }
242
243 if (_begin < _end) {
244 _results.add(String(_end, _end - _begin));
245 }
246
247 return _results.
size();
248}
◆ test() [1/2]
| bool Regex::test |
( |
const char * | _regex, |
|
|
const char * | _string, |
|
|
bool | _icase = false ) |
|
static |
Definition at line 265 of file Regex.cpp.
270{
274 _regex, _regex + ByteString::length(_regex),
275 _string, _string + ByteString::length(_string),
276 _icase
277 ) != (size_t)-1;;
278}
#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 250 of file Regex.cpp.
255{
259 _regex, _regex + String::length(_regex),
260 _string, _string + String::length(_string),
261 _icase
262 ) != (size_t)-1;
263}
The documentation for this class was generated from the following files: