diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-08-27 14:33:36 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-08-27 14:33:36 +0200 |
commit | d7c8e3036f3ee38d5e2354990214ccaaa2a89e5a (patch) | |
tree | 7d2f7f5c31cc370a6a230c9053651cf7211148c7 /cutl/re/re.cxx | |
parent | 526a1773d487207551495e7ca548c9c8876e6898 (diff) |
Reimplement regex support not to rely on any extensions to std::tr1::regex
Diffstat (limited to 'cutl/re/re.cxx')
-rw-r--r-- | cutl/re/re.cxx | 44 |
1 files changed, 14 insertions, 30 deletions
diff --git a/cutl/re/re.cxx b/cutl/re/re.cxx index f2a6a67..c996f4e 100644 --- a/cutl/re/re.cxx +++ b/cutl/re/re.cxx @@ -67,14 +67,14 @@ namespace cutl template <> basic_regex<char>:: basic_regex (basic_regex const& r) - : impl_ (new impl (r.impl_->r)) + : str_ (r.str_), impl_ (new impl (r.impl_->r)) { } template <> basic_regex<wchar_t>:: basic_regex (basic_regex const& r) - : impl_ (new impl (r.impl_->r)) + : str_ (r.str_), impl_ (new impl (r.impl_->r)) { } @@ -82,7 +82,9 @@ namespace cutl basic_regex<char>& basic_regex<char>:: operator= (basic_regex const& r) { + string_type tmp (r.str_); impl_->r = r.impl_->r; + str_.swap (tmp); return *this; } @@ -90,7 +92,9 @@ namespace cutl basic_regex<wchar_t>& basic_regex<wchar_t>:: operator= (basic_regex const& r) { + string_type tmp (r.str_); impl_->r = r.impl_->r; + str_.swap (tmp); return *this; } @@ -98,6 +102,8 @@ namespace cutl void basic_regex<char>:: init (string_type const* s, bool icase) { + string_type tmp (s == 0 ? string_type () : *s); + try { if (impl_ == 0) @@ -111,12 +117,16 @@ namespace cutl { throw basic_format<char> (s == 0 ? "" : *s, e.what ()); } + + str_.swap (tmp); } template <> void basic_regex<wchar_t>:: init (string_type const* s, bool icase) { + string_type tmp (s == 0 ? string_type () : *s); + try { if (impl_ == 0) @@ -130,6 +140,8 @@ namespace cutl { throw basic_format<wchar_t> (s == 0 ? L"" : *s, e.what ()); } + + str_.swap (tmp); } template <> @@ -189,33 +201,5 @@ namespace cutl return tr1::regex_replace (s, impl_->r, sub, f); } - - template <> - string basic_regex<char>:: - str () const - { - return impl_->r.str (); - } - - template <> - wstring basic_regex<wchar_t>:: - str () const - { - return impl_->r.str (); - } - - template <> - bool basic_regex<char>:: - empty () const - { - return impl_->r.empty (); - } - - template <> - bool basic_regex<wchar_t>:: - empty () const - { - return impl_->r.empty (); - } } } |