28 #include <boost/regex.hpp>
29 using namespace boost;
37#if __DCL_HAVE_THIS_FILE__
59#ifdef __DCL_DEBUG_DELETE
61#define delete(_p) __DCL_DEBUG_DELETE(_p)
63 delete ((wregex*)_handle);
64#ifdef __DCL_DEBUG_DELETE
71 const wchar_t* _pattern,
size_t _n,
75 wregex::flag_type flags = wregex::extended;
77 flags |= wregex::icase;
79 flags |= wregex::nosubs;
82 flags |= wregex::newline_alt;
85 ((wregex*)_handle)->assign(_pattern, _pattern + _n, flags);
97 const wchar_t* _begin,
const wchar_t* _end,
101 regex_constants::match_flag_type flags = regex_constants::match_default;
103 flags |= regex_constants::match_not_bol;
105 flags |= regex_constants::match_not_eol;
109 bool b = regex_match(_begin, _end, m, *((
const wregex*)_handle), flags);
113 for(
size_t i = 0; i < m.size(); i++) {
114 match[i].
first = m[i].first;
115 match[i].
second = m[i].second;
116 match[i].
matched = m[i].matched;
127 const wchar_t* _begin,
const wchar_t* _end,
131 regex_constants::match_flag_type flags = regex_constants::match_default;
133 flags |= regex_constants::match_not_bol;
135 flags |= regex_constants::match_not_eol;
138 bool r = regex_match(_begin, _end, *(
const wregex*)_handle, flags);
145 const wchar_t* _begin,
const wchar_t* _end,
149 regex_constants::match_flag_type flags = regex_constants::match_default;
151 flags |= regex_constants::match_not_bol;
153 flags |= regex_constants::match_not_eol;
157 bool r = regex_search(_begin, _end, m, *((
const wregex*)_handle), flags);
161 for(
size_t i = 0; i < m.size(); i++) {
162 match[i].
first = m[i].first;
163 match[i].
second = m[i].second;
164 match[i].
matched = m[i].matched;
175 const wchar_t* _begin,
const wchar_t* _end,
179 regex_constants::match_flag_type flags = regex_constants::match_default;
181 flags |= regex_constants::match_not_bol;
183 flags |= regex_constants::match_not_eol;
186 bool r = regex_search(_begin, _end, *(
const wregex*)_handle, flags);
192 const wchar_t* _regex,
const wchar_t* _regexend,
193 const wchar_t* _begin,
const wchar_t* _end,
197 regex::flag_type flags = regex::ECMAScript;
199 flags |= regex::icase;
204 wregex re(_regex, _regexend, flags);
206 bool r = regex_match(_begin, _end, re);
211 catch (std::exception& e) {
217 const char* _regex,
const char* _regexend,
218 const char* _begin,
const char* _end,
222 regex::flag_type flags = regex::ECMAScript;
224 flags |= regex::icase;
229 regex re(_regex, _regexend, flags);
231 bool r = regex_match(_begin, _end, re);
236 catch (std::exception& e) {
242 const wchar_t* _regex,
const wchar_t* _regexend,
243 const wchar_t* _begin,
const wchar_t* _end,
249 regex::flag_type flags = regex::ECMAScript | regex::nosubs;
251 flags |= regex::icase;
254 size_t r = (size_t)-1;
257 wregex re(_regex, _regexend, flags);
261 if (regex_search(_begin, _end, m, re)) {
262 r = m[0].first - _begin;
267 catch (std::exception& e) {
274 const char* _regex,
const char* _regexend,
275 const char* _begin,
const char* _end,
281 regex::flag_type flags = regex::ECMAScript | regex::nosubs;
283 flags |= regex::icase;
286 size_t r = (size_t)-1;
289 regex re(_regex, _regexend, flags);
293 if (regex_search(_begin, _end, m, re)) {
294 r = m[0].first - _begin;
299 catch (std::exception& e) {
306 const wchar_t* _regex,
const wchar_t* _regexend,
307 const wchar_t* _begin,
const wchar_t* _end,
313 regex::flag_type flags = regex::ECMAScript | regex::nosubs;
315 flags |= regex::icase;
321 wregex re(_regex, _regexend, flags);
325 if (regex_search(_begin, _end, m, re)) {
326 r.assign(m[0].first, m[0].second);
331 catch (std::exception& e) {
338 const char* _regex,
const char* _regexend,
339 const char* _begin,
const char* _end,
345 regex::flag_type flags = regex::ECMAScript | regex::nosubs;
347 flags |= regex::icase;
353 regex re(_regex, _regexend, flags);
358 if (regex_search(_begin, _end, m, re)) {
359 r.assign(m[0].first, m[0].second);
364 catch (std::exception& e) {
371 const wchar_t* _regex,
const wchar_t* _regexend,
372 const wchar_t* _begin,
const wchar_t* _end,
373 const wchar_t* _replacement,
const wchar_t* _replacementend,
378 regex::flag_type flags = regex::ECMAScript | regex::nosubs;
380 flags |= regex::icase;
386 wregex re(_regex, _regexend, flags);
390 while (_begin < _end && _limit && regex_search(_begin, _end, m, re)) {
392 r.append(_begin, m[0].first)
393 .append(_replacement, _replacementend);
396 _begin = m[0].second;
400 r.append(_begin, _end);
406 catch (std::exception& e) {
412 const char* _regex,
const char* _regexend,
413 const char* _begin,
const char* _end,
414 const char* _replacement,
const char* _replacementend,
419 regex::flag_type flags = regex::ECMAScript | regex::nosubs;
421 flags |= regex::icase;
427 regex re(_regex, _regexend, flags);
431 while (_begin < _end && _limit && regex_search(_begin, _end, m, re)) {
433 r.append(_begin, m[0].first)
434 .append(_replacement, _replacementend);
437 _begin = m[0].second;
441 r.append(_begin, _end);
447 catch (std::exception& e) {
453 const wchar_t* _regex,
const wchar_t* _regexend,
454 const wchar_t* _begin,
const wchar_t* _end,
456 StringArray& _results,
460 regex::flag_type flags = regex::ECMAScript | regex::nosubs;
462 flags |= regex::icase;
467 wregex re(_regex, _regexend, flags);
471 while (_begin < _end && _limit && regex_search(_begin, _end, m, re)) {
473 _results.add(String(_begin, m[0].first));
476 _begin = m[0].second;
480 _results.add(String(_begin, _end));
486 catch (std::exception& e) {
492 const char* _regex,
const char* _regexend,
493 const char* _begin,
const char* _end,
495 ByteStringArray& _results,
499 regex::flag_type flags = regex::ECMAScript | regex::nosubs;
501 flags |= regex::icase;
506 regex re(_regex, _regexend, flags);
510 while (_begin < _end && _limit && regex_search(_begin, _end, m, re)) {
512 _results.add(ByteString(_begin, m[0].first));
515 _begin = m[0].second;
519 _results.add(ByteString(_begin, _end));
525 catch (std::exception& e) {
bool __regex_search(regex_handle _handle, const wchar_t *_begin, const wchar_t *_end, match_result **_results, unsigned int _flags)
void __matches_free(match_result *_results)
String __regex_substring(const wchar_t *_regex, const wchar_t *_regexend, const wchar_t *_begin, const wchar_t *_end, bool _icase) __DCL_THROWS1(RegexException *)
StringArray & __regex_split(const wchar_t *_regex, const wchar_t *_regexend, const wchar_t *_begin, const wchar_t *_end, bool _icase, StringArray &_results, size_t _limit) __DCL_THROWS1(RegexException *)
size_t __regex_match(regex_handle _handle, const wchar_t *_begin, const wchar_t *_end, match_result **_results, unsigned int _flags)
String __regex_replace(const wchar_t *_regex, const wchar_t *_regexend, const wchar_t *_begin, const wchar_t *_end, const wchar_t *_replacement, const wchar_t *_replacementend, bool _icase, size_t _limit) __DCL_THROWS1(RegexException *)
__DCL_BEGIN_NAMESPACE regex_handle __regex_create()
bool __regex_matches(const wchar_t *_regex, const wchar_t *_regexend, const wchar_t *_begin, const wchar_t *_end, bool _icase) __DCL_THROWS1(RegexException *)
void __regex_compile(regex_handle _handle, const wchar_t *_pattern, size_t _n, unsigned int _flags)
void __regex_destroy(regex_handle _handle)
#define __DCL_DEBUG_ALLOC_LEAVE
#define __DCL_ASSERT(expr)
#define __DCL_DEBUG_ALLOC_ENTER