optimized set of C chars, with quick membership test and merge support More...

#include <CharacterSet.h>

Collaboration diagram for CharacterSet:

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...
 
CharacterSetadd (const unsigned char c)
 add a given character to the character set More...
 
CharacterSetremove (const unsigned char c)
 remove a given character from the character set More...
 
CharacterSetaddRange (unsigned char low, unsigned char high)
 add a list of character ranges, expressed as pairs [low,high], including both ends More...
 
CharacterSetoperator+= (const CharacterSet &rhs)
 set addition: add to this set all characters that are also in rhs More...
 
CharacterSetoperator-= (const CharacterSet &rhs)
 set subtraction: remove all characters that are also in rhs More...
 
CharacterSet complement (const char *complementLabel=nullptr) const
 
CharacterSetrename (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

Definition at line 20 of file CharacterSet.h.

Constructor & Destructor Documentation

◆ CharacterSet() [1/3]

CharacterSet::CharacterSet ( const char *  label = "anonymous",
const char *const  chars = "" 
)
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)

◆ 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()

bool CharacterSet::isEmpty ( ) const
inline

Definition at line 36 of file CharacterSet.h.

References chars_.

◆ operator!=()

bool CharacterSet::operator!= ( const CharacterSet cs) const
inline
Note
Ignores label

Definition at line 66 of file CharacterSet.h.

References operator==().

◆ 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==()

bool CharacterSet::operator== ( const CharacterSet cs) const
inline
Note
Ignores label

Definition at line 64 of file CharacterSet.h.

References chars_.

Referenced by operator!=().

◆ operator[]()

bool CharacterSet::operator[] ( unsigned char  c) const
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()

CharacterSet & CharacterSet::rename ( const char *  label)
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

◆ BIT

const CharacterSet CharacterSet::BIT
static

Definition at line 78 of file CharacterSet.h.

Referenced by TestCharacterSet::CharacterSetEqualityOp().

◆ chars_

Storage CharacterSet::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

◆ CTEXT

const CharacterSet CharacterSet::CTEXT
static

Definition at line 102 of file CharacterSet.h.

◆ CTL

const CharacterSet CharacterSet::CTL
static

Definition at line 82 of file CharacterSet.h.

◆ DIGIT

◆ DQUOTE

const CharacterSet CharacterSet::DQUOTE
static

Definition at line 86 of file CharacterSet.h.

◆ ETAGC

const CharacterSet CharacterSet::ETAGC
static

Definition at line 115 of file CharacterSet.h.

◆ HEXDIG

◆ HTAB

const CharacterSet CharacterSet::HTAB
static

◆ LF

◆ name

◆ OBSTEXT

const CharacterSet CharacterSet::OBSTEXT
static

◆ QDTEXT

const CharacterSet CharacterSet::QDTEXT
static

Definition at line 109 of file CharacterSet.h.

◆ SP

◆ SPECIAL

const CharacterSet CharacterSet::SPECIAL
static

Definition at line 107 of file CharacterSet.h.

◆ TCHAR

◆ TOKEN68C

const CharacterSet CharacterSet::TOKEN68C
static

Definition at line 119 of file CharacterSet.h.

◆ VCHAR

const CharacterSet CharacterSet::VCHAR
static

◆ WSP


The documentation for this class was generated from the following files:

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors