]>
Commit | Line | Data |
---|---|---|
8fcefb30 | 1 | /* |
f70aedc4 | 2 | * Copyright (C) 1996-2021 The Squid Software Foundation and contributors |
8fcefb30 AJ |
3 | * |
4 | * Squid software is distributed under GPLv2+ license and includes | |
5 | * contributions from numerous individuals and organizations. | |
6 | * Please see the COPYING and CONTRIBUTORS files for details. | |
7 | */ | |
8 | ||
9 | #ifndef SQUID_SRC_BASE_REGEXPATTERN_H | |
10 | #define SQUID_SRC_BASE_REGEXPATTERN_H | |
11 | ||
c2afddd8 | 12 | #include "compat/GnuRegex.h" |
8fcefb30 AJ |
13 | #include "mem/forward.h" |
14 | ||
15 | /** | |
16 | * A regular expression, | |
17 | * plain text and compiled representations | |
18 | */ | |
19 | class RegexPattern | |
20 | { | |
21 | MEMPROXY_CLASS(RegexPattern); | |
22 | ||
23 | public: | |
24 | RegexPattern() = delete; | |
c2afddd8 AJ |
25 | RegexPattern(int aFlags, const char *aPattern); |
26 | ~RegexPattern(); | |
27 | ||
28 | // regex type varies by library, usually not safe to copy | |
b9a9207b AJ |
29 | RegexPattern(const RegexPattern &) = delete; |
30 | RegexPattern &operator =(const RegexPattern &) = delete; | |
c2afddd8 AJ |
31 | |
32 | RegexPattern(RegexPattern &&); | |
b9a9207b AJ |
33 | RegexPattern &operator =(RegexPattern &&); |
34 | ||
c2afddd8 AJ |
35 | const char * c_str() const {return pattern;} |
36 | bool match(const char *str) const {return regexec(®ex,str,0,NULL,0)==0;} | |
95b8eae2 AJ |
37 | |
38 | public: | |
c2afddd8 AJ |
39 | int flags; |
40 | regex_t regex; | |
95b8eae2 AJ |
41 | |
42 | private: | |
43 | char *pattern; | |
8fcefb30 AJ |
44 | }; |
45 | ||
8fcefb30 AJ |
46 | #endif /* SQUID_SRC_BASE_REGEXPATTERN_H */ |
47 |