]> git.ipfire.org Git - thirdparty/squid.git/blob - src/base/RegexPattern.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / base / RegexPattern.h
1 /*
2 * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
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
12 #include "compat/GnuRegex.h"
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;
25 RegexPattern(int aFlags, const char *aPattern);
26 RegexPattern(const RegexPattern &) = delete;
27 RegexPattern(RegexPattern &&) = default;
28 ~RegexPattern();
29
30 const char * c_str() const {return pattern;}
31 bool match(const char *str) const {return regexec(&regex,str,0,NULL,0)==0;}
32
33 public:
34 int flags;
35 regex_t regex;
36
37 private:
38 char *pattern;
39 };
40
41 #endif /* SQUID_SRC_BASE_REGEXPATTERN_H */
42