Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
71 lines (60 loc) · 1.43 KB

File metadata and controls

71 lines (60 loc) · 1.43 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
///////////////////////////////////////////////////////////////
// Copyright 2015 John Maddock. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_
//
#ifdef TEST_RE2
#include "performance.hpp"
#include <boost/scoped_ptr.hpp>
#include <re2.h>
using namespace re2;
struct re2_regex : public abstract_regex
{
private:
boost::scoped_ptr<RE2> pat;
public:
re2_regex() {}
~re2_regex(){}
virtual bool set_expression(const char* pp, bool isperl)
{
if(!isperl)
return false;
std::string s("(?m)");
s += pp;
pat.reset(new RE2(s));
return pat->ok();
}
virtual bool match_test(const char* text);
virtual unsigned find_all(const char* text);
virtual std::string name();
struct initializer
{
initializer()
{
re2_regex::register_instance(boost::shared_ptr<abstract_regex>(new re2_regex));
}
void do_nothing()const {}
};
static const initializer init;
};
const re2_regex::initializer re2_regex::init;
bool re2_regex::match_test(const char * text)
{
return RE2::FullMatch(text, *pat);
}
unsigned re2_regex::find_all(const char * text)
{
unsigned count = 0;
StringPiece input(text);
while(RE2::FindAndConsume(&input, *pat))
{
++count;
}
return count;
}
std::string re2_regex::name()
{
init.do_nothing();
return "RE2";
}
#endif
Morty Proxy This is a proxified and sanitized view of the page, visit original site.