]> git.ipfire.org Git - thirdparty/squid.git/blame - src/base/CharacterSet.h
Merged from trunk
[thirdparty/squid.git] / src / base / CharacterSet.h
CommitLineData
3c1106a0
FC
1#ifndef _SQUID_SRC_PARSER_CHARACTERSET_H
2#define _SQUID_SRC_PARSER_CHARACTERSET_H
3
4#include <vector>
5
0e4d80e4 6/// Optimized set of C chars, with quick membership test and merge support
3c1106a0
FC
7class CharacterSet
8{
9public:
0e4d80e4
FC
10 typedef std::vector<uint8_t> vector_type;
11
dcd4fdac 12 CharacterSet(const char *label, const char * const c);
3c1106a0
FC
13
14 /// whether a given character exists in the set
dcd4fdac 15 bool operator[](unsigned char c) const {return chars_[static_cast<uint8_t>(c)] == 1;}
3c1106a0 16
0e4d80e4 17 /// add a given char to the character set.
dcd4fdac 18 CharacterSet & add(const unsigned char c);
3c1106a0
FC
19
20 /// add all characters from the given CharacterSet to this one
c8046ec7 21 const CharacterSet &operator +=(const CharacterSet &src);
3c1106a0 22
0e4d80e4 23 /// optional set label fdebugging (default: "anonymous")
3c1106a0
FC
24 const char * name;
25
26private:
dcd4fdac
FC
27 /** characters present in this set.
28 *
29 * \note guaranteed to be always 256 slots wide, as forced in the
30 * constructor. This assumption is relied upon in operator[], add,
31 * operator+=
32 */
0e4d80e4 33 vector_type chars_;
3c1106a0
FC
34};
35
36#endif /* _SQUID_SRC_PARSER_CHARACTERSET_H */