10#if __DCL_HAVE_ALLOC_DEBUG
11#undef __DCL_ALLOC_LEVEL
12#define __DCL_ALLOC_LEVEL __DCL_ALLOC_INTERNAL
15#if __DCL_HAVE_THIS_FILE__
24RegexException::RegexException(
const char* _name,
const char* _what)
53void Regex::MatchResults::attach(
match_result* _results,
size_t _size)
69 if (!(_index < __size)) {
72 return __results[_index];
100 compile(_pattern.data(), _pattern.length(), _flags);
115 catch (std::exception& e) {
131 catch (std::exception& e) {
146 size_t n =
__regex_search(__handle, _begin, _end, &results, _flags);
148 _results.attach(results, n);
153 catch (std::exception& e) {
171 catch (std::exception& e) {
186 size_t n =
__regex_match(__handle, _begin, _end, &results, _flags);
188 _results.attach(results, n);
193 catch (std::exception& e) {
201 const String& _string,
202 const String& _replacement,
206 const wchar_t* _begin = _string.data();
207 const wchar_t* _end = _string.data() + _string.length();
211 while (_begin < _end && 0 < _limit &&
search(_begin, _end, results)) {
212 r.append(_begin, results[0].first);
213 r.append(_replacement);
216 _begin = results[0].second;
220 r.append(_begin, _end);
227 const wchar_t* _begin,
const wchar_t* _end,
228 StringArray& _results,
236 while(_begin < _end && _limit > 0 &&
search(_begin, _end, results)) {
237 _results.add(String(_begin, results[0].first - _begin));
240 _begin = results[0].second;
244 _results.add(String(_end, _end - _begin));
247 return _results.size();
251 const wchar_t* _regex,
252 const wchar_t* _string,
259 _regex, _regex + String::length(_regex),
260 _string, _string + String::length(_string),
274 _regex, _regex + ByteString::length(_regex),
275 _string, _string + ByteString::length(_string),
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)
regex_handle __regex_create()
size_t __regex_match(regex_handle _handle, const wchar_t *_begin, const wchar_t *_end, match_result **_results, unsigned int _flags)
void __regex_compile(regex_handle _handle, const wchar_t *_pattern, size_t _n, unsigned int _flags)
void __regex_destroy(regex_handle _handle)
#define __DCL_ASSERT_PARAM(expr)
#define __DCL_ASSERT(expr)
#define IMPLEMENT_CLASSINFO(class_name, base_class_name)
static String decode(const char *_mbs, size_t _mbslen=(size_t) -1)
virtual String toString() const
const match_result & operator[](size_t _index) const __DCL_THROWS1(InvalidIndexException *)
size_t split(const wchar_t *_begin, const wchar_t *_end, StringArray &_results, size_t _limit=(size_t) -1) __DCL_THROWS1(RegexException *)
bool search(const wchar_t *_begin, const wchar_t *_end, unsigned int _flags=0) __DCL_THROWS1(RegexException *)
bool match(const wchar_t *_begin, const wchar_t *_end, unsigned int _flags) __DCL_THROWS1(RegexException *)
void compile(const wchar_t *_pattern, size_t _n, unsigned int _flags=0) __DCL_THROWS1(RegexException *)
String replace(const String &_string, const String &_replacement, size_t _limit=(size_t) -1) __DCL_THROWS1(RegexException *)
static bool test(const wchar_t *_regex, const wchar_t *_string, bool _icase=false) __DCL_THROWS1(RegexException *)