#include <xrb_characterfilter.hpp>
Public Types | |
enum | FilterType { ALLOW = 0, DENY } |
Enumerates the two filter types. More... | |
Public Member Functions | |
CharacterFilter () | |
Default constructor. | |
CharacterFilter (FilterType const filter_type, std::string const &filter) | |
Construct a filter with the given type and filter string. | |
~CharacterFilter () | |
Boring old destructor. | |
FilterType | GetFilterType () const |
Returns the filter type. | |
std::string const & | Filter () const |
Returns the string containing the filter characters. | |
char | FilteredCharacter (char c) const |
Returns the filtered version of the given character. | |
void | SetFilterType (FilterType const filter_type) |
Sets the filter type. | |
void | SetFilter (std::string const &filter) |
Sets the string containing the filter chars. |
The filtering functionality operates by allowing or denying characters on a character-by-character basis. If a character is allowed, its value is returned unchanged by FilteredCharacter. If it is denied, then '' is returned.
There are two types of operation for the filter; allow-only-chars and deny-only-chars. Allow-only-chars indicates that only the characters found in the filter string should be passed through the filter. Deny-only-chars indicates only the characters not found in the filter string should be passed through the filter.
Definition at line 34 of file xrb_characterfilter.hpp.
Enumerates the two filter types.
ALLOW | Allow-only-chars - pass only the chars found in the filter string. |
DENY | Deny-only-chars - pass only the chars not found in the filter string. |
Definition at line 40 of file xrb_characterfilter.hpp.
Xrb::CharacterFilter::CharacterFilter | ( | ) | [inline] |
Default constructor.
The default filter mode is deny-only-chars, with the filter string being empty, meaning that no characters are filtered out.
Definition at line 50 of file xrb_characterfilter.hpp.
References DENY.
Xrb::CharacterFilter::CharacterFilter | ( | FilterType const | filter_type, | |
std::string const & | filter | |||
) | [inline] |
Construct a filter with the given type and filter string.
filter_type | The filter type to use. | |
filter | The string containing the filter characters. |
Definition at line 58 of file xrb_characterfilter.hpp.
char Xrb::CharacterFilter::FilteredCharacter | ( | char | c | ) | const |
Returns the filtered version of the given character.
If the given character is filtered out, '' will be returned.
c | The character to filter. |
Definition at line 16 of file xrb_characterfilter.cpp.
References ALLOW, DENY, Filter(), and GetFilterType().
void Xrb::CharacterFilter::SetFilterType | ( | FilterType const | filter_type | ) | [inline] |
Sets the filter type.
param filter_type The filter type to use.
Definition at line 90 of file xrb_characterfilter.hpp.
void Xrb::CharacterFilter::SetFilter | ( | std::string const & | filter | ) | [inline] |
Sets the string containing the filter chars.
filter | The new filter string to use. |
Definition at line 97 of file xrb_characterfilter.hpp.