From a15cf65c44d5c224169c32ef5495b68c758134b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 18 May 2014 16:08:14 +0200 Subject: Imported Upstream version 3.3.0.2 --- libbackend-elements/backend-elements/regex.txx | 52 ++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 libbackend-elements/backend-elements/regex.txx (limited to 'libbackend-elements/backend-elements/regex.txx') diff --git a/libbackend-elements/backend-elements/regex.txx b/libbackend-elements/backend-elements/regex.txx new file mode 100644 index 0000000..897e0e8 --- /dev/null +++ b/libbackend-elements/backend-elements/regex.txx @@ -0,0 +1,52 @@ +// file : backend-elements/regex.txx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 Boris Kolpackov +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace BackendElements +{ + namespace Regex + { + template + Void Pattern:: + init (StringTemplate const& r) + { + try + { + pat_ = r; + } + catch (boost::regex_error const& e) + { + throw Format (r, e.what ()); + } + } + + // + // + template + Void Expression:: + init (StringTemplate const& r) + { + typedef StringTemplate String; + + if (r.empty ()) + throw Format (r, "empty expression"); + + C d (r[0]); + + Size first (0); + Size middle (r.find (d, first + 1)); + + if (middle == String::npos) + throw Format (r, "missing second pattern-substitution separator"); + + Size last (r.find (d, middle + 1)); + + if (last == String::npos) + throw Format (r, "missing third pattern-substitution separator"); + + pat_ = String (r, first + 1, middle - first - 1); + sub_.assign (r, middle + 1, last - middle - 1); + } + } +} -- cgit v1.2.3