-
Notifications
You must be signed in to change notification settings - Fork 0
/
std_regex.H
60 lines (41 loc) · 876 Bytes
/
std_regex.H
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
#ifndef STD_REGEX_H
#define STD_REGEX_H
#include <string>
#include <list>
#include <memory>
#include <regex>
class String;
class Match {
public:
/// Ctor
Match() = default;
/// Dtor
~Match() = default;
inline size_t position() const
{
return _smatch.position();
}
inline size_t length() const
{
return _smatch.length();
}
inline std::smatch & smatch()
{
return _smatch;
}
private:
std::smatch _smatch;
};
class Regex {
public:
typedef std::unique_ptr<Regex> Ptr;
typedef std::list<Ptr> PtrList;
explicit Regex(String const & r, std::string const & grammar);
~Regex();
inline bool valid() const { return _valid; }
bool match(std::string const & s, Match * pmatch = nullptr) const;
private:
bool _valid;
std::regex _preg;
};
#endif // STD_REGEX_H