blob: 897e0e8be91114376cfa112c26413a896162951c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
// file : backend-elements/regex.txx
// author : Boris Kolpackov <boris@kolpackov.net>
// copyright : Copyright (c) 2005-2010 Boris Kolpackov
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
namespace BackendElements
{
namespace Regex
{
template <typename C>
Void Pattern<C>::
init (StringTemplate<C> const& r)
{
try
{
pat_ = r;
}
catch (boost::regex_error const& e)
{
throw Format<C> (r, e.what ());
}
}
//
//
template <typename C>
Void Expression<C>::
init (StringTemplate<C> const& r)
{
typedef StringTemplate<C> String;
if (r.empty ())
throw Format<C> (r, "empty expression");
C d (r[0]);
Size first (0);
Size middle (r.find (d, first + 1));
if (middle == String::npos)
throw Format<C> (r, "missing second pattern-substitution separator");
Size last (r.find (d, middle + 1));
if (last == String::npos)
throw Format<C> (r, "missing third pattern-substitution separator");
pat_ = String (r, first + 1, middle - first - 1);
sub_.assign (r, middle + 1, last - middle - 1);
}
}
}
|