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...
 
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

Definition at line 20 of file CharacterSet.h.

Constructor & Destructor Documentation

CharacterSet::CharacterSet ( const char *  label = "anonymous",
const char *const  chars = "" 
)
explicit

Definition at line 76 of file CharacterSet.cc.

References add(), and i.

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 85 of file CharacterSet.cc.

References addRange().

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 92 of file CharacterSet.cc.

References addRange().

Member Function Documentation

CharacterSet & CharacterSet::add ( const unsigned char  c)
CharacterSet & CharacterSet::addRange ( unsigned char  low,
unsigned char  high 
)

Definition at line 54 of file CharacterSet.cc.

References chars_.

Referenced by CharacterSet(), and testCharacterSet::CharacterSetAddRange().

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 67 of file CharacterSet.cc.

References chars_.

Referenced by Ftp::Server::handleFeatReply(), LineCharacters(), Ftp::Server::parseOneRequest(), ConnStateData::parseProxy1p0(), and Http::One::RequestParser::parseRequestFirstLine().

bool CharacterSet::isEmpty ( ) const
inline

Definition at line 36 of file CharacterSet.h.

References chars_.

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

Definition at line 63 of file CharacterSet.h.

References operator==().

CharacterSet & CharacterSet::operator+= ( const CharacterSet rhs)

Definition at line 17 of file CharacterSet.cc.

References chars_.

CharacterSet & CharacterSet::operator-= ( const CharacterSet rhs)

Definition at line 32 of file CharacterSet.cc.

References chars_.

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

Definition at line 61 of file CharacterSet.h.

References chars_.

Referenced by operator!=().

bool CharacterSet::operator[] ( unsigned char  c) const
inline

Definition at line 39 of file CharacterSet.h.

References chars_.

void CharacterSet::printChars ( std::ostream &  os) const

Definition at line 101 of file CharacterSet.cc.

References chars_.

CharacterSet& CharacterSet::rename ( const char *  label)
inline

Definition at line 58 of file CharacterSet.h.

References name.

Referenced by Http::One::Parser::unfoldMime().

Member Data Documentation

const CharacterSet CharacterSet::BIT
static

Definition at line 75 of file CharacterSet.h.

Referenced by testCharacterSet::CharacterSetEqualityOp().

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 124 of file CharacterSet.h.

Referenced by add(), addRange(), complement(), isEmpty(), operator+=(), operator-=(), operator==(), operator[](), and printChars().

const CharacterSet CharacterSet::CTEXT
static

Definition at line 99 of file CharacterSet.h.

const CharacterSet CharacterSet::CTL
static

Definition at line 79 of file CharacterSet.h.

const CharacterSet CharacterSet::DQUOTE
static

Definition at line 83 of file CharacterSet.h.

const CharacterSet CharacterSet::ETAGC
static

Definition at line 112 of file CharacterSet.h.

const CharacterSet CharacterSet::OBSTEXT
static
const CharacterSet CharacterSet::QDTEXT
static

Definition at line 106 of file CharacterSet.h.

const CharacterSet CharacterSet::SPECIAL
static

Definition at line 104 of file CharacterSet.h.

const CharacterSet CharacterSet::TOKEN68C
static

Definition at line 116 of file CharacterSet.h.

const CharacterSet CharacterSet::VCHAR
static

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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors