optimized set of C chars, with quick membership test and merge support More...
#include <CharacterSet.h>
Public Types | |
typedef std::vector< uint8_t > | Storage |
Public Member Functions | |
CharacterSet (const char *label="anonymous", const char *const chars="") | |
a character set with a given label and contents More... | |
CharacterSet (const char *label, unsigned char low, unsigned char high) | |
CharacterSet (const char *label, std::initializer_list< std::pair< uint8_t, uint8_t > > ranges) | |
bool | isEmpty () const |
whether the set lacks any members More... | |
bool | operator[] (unsigned char c) const |
whether a given character exists in the set More... | |
CharacterSet & | add (const unsigned char c) |
add a given character to the character set More... | |
CharacterSet & | remove (const unsigned char c) |
remove a given character from the character set More... | |
CharacterSet & | addRange (unsigned char low, unsigned char high) |
add a list of character ranges, expressed as pairs [low,high], including both ends More... | |
CharacterSet & | operator+= (const CharacterSet &rhs) |
set addition: add to this set all characters that are also in rhs More... | |
CharacterSet & | operator-= (const CharacterSet &rhs) |
set subtraction: remove all characters that are also in rhs More... | |
CharacterSet | complement (const char *complementLabel=nullptr) const |
CharacterSet & | rename (const char *label) |
change name; handy in const declarations that use operators More... | |
bool | operator== (const CharacterSet &cs) const |
bool | operator!= (const CharacterSet &cs) const |
void | printChars (std::ostream &os) const |
prints all chars in arbitrary order, without any quoting/escaping More... | |
Public Attributes | |
const char * | name |
optional set label for debugging (default: "anonymous") More... | |
Static Public Attributes | |
static const CharacterSet | ALPHA |
static const CharacterSet | BIT |
static const CharacterSet | CR |
static const CharacterSet | CTL |
static const CharacterSet | DIGIT |
static const CharacterSet | DQUOTE |
static const CharacterSet | HEXDIG |
static const CharacterSet | HTAB |
static const CharacterSet | LF |
static const CharacterSet | SP |
static const CharacterSet | VCHAR |
static const CharacterSet | WSP |
static const CharacterSet | CTEXT |
static const CharacterSet | TCHAR |
static const CharacterSet | SPECIAL |
static const CharacterSet | QDTEXT |
static const CharacterSet | OBSTEXT |
static const CharacterSet | ETAGC |
static const CharacterSet | TOKEN68C |
Private Attributes | |
Storage | chars_ |
Detailed Description
Definition at line 17 of file CharacterSet.h.
Member Typedef Documentation
◆ Storage
typedef std::vector<uint8_t> CharacterSet::Storage |
Definition at line 20 of file CharacterSet.h.
Constructor & Destructor Documentation
◆ CharacterSet() [1/3]
|
explicit |
Definition at line 83 of file CharacterSet.cc.
References add().
◆ CharacterSet() [2/3]
CharacterSet::CharacterSet | ( | const char * | label, |
unsigned char | low, | ||
unsigned char | high | ||
) |
define a character set with the given label ("anonymous" if nullptr) containing characters defined in the supplied ranges
- See also
- addRange
Definition at line 92 of file CharacterSet.cc.
References addRange().
◆ CharacterSet() [3/3]
CharacterSet::CharacterSet | ( | const char * | label, |
std::initializer_list< std::pair< uint8_t, uint8_t > > | ranges | ||
) |
define a character set with the given label ("anonymous" if nullptr) containing characters defined in the supplied list of low-high ranges
- See also
- addRange
Definition at line 99 of file CharacterSet.cc.
References addRange().
Member Function Documentation
◆ add()
CharacterSet & CharacterSet::add | ( | const unsigned char | c | ) |
Definition at line 47 of file CharacterSet.cc.
References chars_.
Referenced by CharacterSet(), TestCharacterSet::CharacterSetAdd(), IgnorePlaceholder(), TestTokenizer::testTokenizerPrefix(), and TestTokenizer::testTokenizerSuffix().
◆ addRange()
CharacterSet & CharacterSet::addRange | ( | unsigned char | low, |
unsigned char | high | ||
) |
Definition at line 61 of file CharacterSet.cc.
References chars_.
Referenced by CharacterSet(), and TestCharacterSet::CharacterSetAddRange().
◆ complement()
CharacterSet CharacterSet::complement | ( | const char * | complementLabel = nullptr | ) | const |
return a new CharacterSet containing characters not in this set use the supplied label if provided, default is "complement_of_some_other_set"
Definition at line 74 of file CharacterSet.cc.
References chars_.
Referenced by asnAddNet(), Ftp::Server::handleFeatReply(), LineCharacters(), ProxyProtocol::One::Parse(), Mgr::QueryParams::Parse(), Ftp::Server::parseOneRequest(), Http::One::RequestParser::parseRequestFirstLine(), and CacheManager::ParseUrl().
◆ isEmpty()
|
inline |
Definition at line 36 of file CharacterSet.h.
References chars_.
◆ operator!=()
|
inline |
◆ operator+=()
CharacterSet & CharacterSet::operator+= | ( | const CharacterSet & | rhs | ) |
Definition at line 17 of file CharacterSet.cc.
References chars_.
◆ operator-=()
CharacterSet & CharacterSet::operator-= | ( | const CharacterSet & | rhs | ) |
Definition at line 32 of file CharacterSet.cc.
References chars_.
◆ operator==()
|
inline |
- Note
- Ignores label
Definition at line 64 of file CharacterSet.h.
References chars_.
Referenced by operator!=().
◆ operator[]()
|
inline |
Definition at line 39 of file CharacterSet.h.
References chars_.
◆ printChars()
void CharacterSet::printChars | ( | std::ostream & | os | ) | const |
Definition at line 108 of file CharacterSet.cc.
References chars_.
◆ remove()
CharacterSet & CharacterSet::remove | ( | const unsigned char | c | ) |
Definition at line 54 of file CharacterSet.cc.
References chars_.
Referenced by AnyP::Uri::absolute().
◆ rename()
|
inline |
Definition at line 61 of file CharacterSet.h.
References name.
Referenced by AnyP::Uri::absolute(), ProxyProtocol::One::Parse(), and Http::One::Parser::unfoldMime().
Member Data Documentation
◆ ALPHA
|
static |
Definition at line 76 of file CharacterSet.h.
Referenced by TestCharacterSet::CharacterSetConstants(), TestCharacterSet::CharacterSetEqualityOp(), Http::One::Parser::getHostHeaderField(), hostname_check(), mainHandleCommandLineOption(), Mgr::QueryParams::Parse(), Security::PeerOptions::parseOptions(), AnyP::Uri::parseUrn(), prepareAcceleratedURL(), uriParseScheme(), UriValidCharacters(), UserInfoChars(), and Notes::validateKey().
◆ BIT
|
static |
Definition at line 78 of file CharacterSet.h.
Referenced by TestCharacterSet::CharacterSetEqualityOp().
◆ chars_
|
private |
index of characters in this set
- Note
- guaranteed to be always 256 slots big, as forced in the constructor. This assumption is relied upon in various methods
Definition at line 127 of file CharacterSet.h.
Referenced by add(), addRange(), complement(), isEmpty(), operator+=(), operator-=(), operator==(), operator[](), printChars(), and remove().
◆ CR
|
static |
Definition at line 80 of file CharacterSet.h.
Referenced by GetOtherPid(), ProxyProtocol::One::Parse(), parseQuotedStringSuffix(), RelaxedDelimiterCharacters(), Http::One::RequestParser::skipTrailingCrs(), and Http::One::Parser::unfoldMime().
◆ CTEXT
|
static |
Definition at line 102 of file CharacterSet.h.
◆ CTL
|
static |
Definition at line 82 of file CharacterSet.h.
◆ DIGIT
|
static |
Definition at line 84 of file CharacterSet.h.
Referenced by TestCharacterSet::CharacterSetUnion(), ConfigureCurrentKid(), ProxyProtocol::FieldNameToFieldType(), Http::ContentLengthInterpreter::findDigits(), Http::One::Parser::getHostHeaderField(), hostname_check(), mainHandleCommandLineOption(), Mgr::QueryParams::Parse(), Http::One::RequestParser::parseHttpVersionField(), Security::PeerOptions::parseOptions(), AnyP::Uri::parseUrn(), prepareAcceleratedURL(), uriParseScheme(), UriValidCharacters(), UserInfoChars(), and Notes::validateKey().
◆ DQUOTE
|
static |
Definition at line 86 of file CharacterSet.h.
◆ ETAGC
|
static |
Definition at line 115 of file CharacterSet.h.
◆ HEXDIG
|
static |
Definition at line 88 of file CharacterSet.h.
Referenced by TestCharacterSet::CharacterSetSubtract(), TestCharacterSet::CharacterSetUnion(), ProxyProtocol::One::ExtractIp(), AnyP::Uri::parseHost(), prepareAcceleratedURL(), and UriValidCharacters().
◆ HTAB
|
static |
Definition at line 90 of file CharacterSet.h.
Referenced by Auth::SchemesConfig::expand(), parseQuotedStringSuffix(), and RelaxedDelimiterCharacters().
◆ LF
|
static |
Definition at line 92 of file CharacterSet.h.
Referenced by Http::One::Parser::cleanMimePrefix(), Http::One::Parser::getHostHeaderField(), GetOtherPid(), LineCharacters(), Ftp::Server::parseOneRequest(), parseQuotedStringSuffix(), Http::One::RequestParser::parseRequestFirstLine(), Http::One::Parser::skipLineTerminator(), and Http::One::Parser::unfoldMime().
◆ name
const char* CharacterSet::name |
Definition at line 72 of file CharacterSet.h.
Referenced by TestCharacterSet::CharacterSetConstruction(), SBuf::findFirstNotOf(), SBuf::findFirstOf(), SBuf::findLastNotOf(), SBuf::findLastOf(), operator<<(), parseQuotedStringSuffix(), Parser::Tokenizer::prefix(), rename(), Parser::Tokenizer::skipAll(), Parser::Tokenizer::skipAllTrailing(), Parser::Tokenizer::skipOne(), Parser::Tokenizer::skipOneTrailing(), and Parser::Tokenizer::token().
◆ OBSTEXT
|
static |
Definition at line 111 of file CharacterSet.h.
Referenced by parseQuotedStringSuffix(), and Http::One::ResponseParser::parseResponseStatusAndReason().
◆ QDTEXT
|
static |
Definition at line 109 of file CharacterSet.h.
◆ SP
|
static |
Definition at line 94 of file CharacterSet.h.
Referenced by Http::One::Parser::DelimiterCharacters(), Auth::SchemesConfig::expand(), Ftp::Server::handleFeatReply(), parseQuotedStringSuffix(), and RelaxedDelimiterCharacters().
◆ SPECIAL
|
static |
Definition at line 107 of file CharacterSet.h.
◆ TCHAR
|
static |
Definition at line 105 of file CharacterSet.h.
Referenced by HttpHeaderEntry::parse(), AnyP::Uri::parseHost(), Http::One::RequestParser::parseMethodField(), Http::One::TeChunkedParser::parseOneChunkExtension(), and Http::One::tokenOrQuotedString().
◆ TOKEN68C
|
static |
Definition at line 119 of file CharacterSet.h.
◆ VCHAR
|
static |
Definition at line 96 of file CharacterSet.h.
Referenced by parseQuotedStringSuffix(), and Http::One::ResponseParser::parseResponseStatusAndReason().
◆ WSP
|
static |
Definition at line 98 of file CharacterSet.h.
Referenced by Http::One::Parser::getHostHeaderField(), Http::One::ResponseParser::parseResponseStatusAndReason(), Http::One::Parser::unfoldMime(), and Http::One::Parser::WhitespaceCharacters().
The documentation for this class was generated from the following files:
- src/base/CharacterSet.h
- src/base/CharacterSet.cc