ionflux.org | Impressum

Ionflux::Tools::StringFilter Class Reference
[String filters]

String filter. More...

#include <StringFilter.hpp>

Collaboration diagram for Ionflux::Tools::StringFilter:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 StringFilter ()
 Constructor.
 StringFilter (const std::string &initFilter)
 Constructor.
virtual ~StringFilter ()
 Destructor.
virtual void setFilter (const std::string &newFilter)
 Sets filter expression.
virtual void addManipulator (StringManipulator *newManip, bool manage)
 Add a string manipulator.
virtual std::string apply (const std::string &bytes)
 Apply filter.
virtual void printDebugInfo ()
 Print debug information.
virtual ReportergetLog ()
 Get Console output/logging facility.

Static Public Attributes

static const TokenType TT_FUNC_SEP
 Token type: Function separator.
static const TokenType TT_FUNC_BRACKET_LEFT
 Token type: Function left bracket.
static const TokenType TT_FUNC_BRACKET_RIGHT
 Token type: Function right bracket.
static const TokenType TT_FUNC_ARG_DELIM
 Token type: Argument delimiter.
static const TokenType TT_FUNC_ARG_SEP
 Token type: Argument separator.

Protected Member Functions

virtual void clearFunctions ()
 Delete all functions.
virtual void clearManipulators ()
 Delete string manipulators.
virtual void initTokenTypes ()
 Initialize token types.
virtual void initManipulators ()
 Initialize string manipulators.
virtual void parse ()
 Parse filter expression.
virtual StringManipulatorgetManipulator (const std::string &manipName)
 Get string manipulator by name.

Protected Attributes

Ionflux::Tools::Reporter log
 Console output/logging.
std::string filter
 The filter expression.
std::vector< StringFilterFunction * > functions
 The functions in this filter.
std::vector< StringManipulatorEntrymanipulators
 String manipulators available to this filter.
std::map< std::string, StringManipulator * > manipIndex
 String manipulator index map.
Tokenizer tok
 Tokenizer for parsing filter expressions.

Static Protected Attributes

static StringUppercase STRINGMANIP_UPPERCASE
 String manipulator: uppercase.
static StringLowercase STRINGMANIP_LOWERCASE
 String manipulator: lowercase.
static StringErase STRINGMANIP_ERASE
 String manipulator: erase.
static StringReplace STRINGMANIP_REPLACE
 String manipulator: replace.
static StringTrim STRINGMANIP_TRIM
 String manipulator: trim.
static StringLTrim STRINGMANIP_LTRIM
 String manipulator: ltrim.
static StringRTrim STRINGMANIP_RTRIM
 String manipulator: rtrim.
static StringTruncate STRINGMANIP_TRUNCATE
 String manipulator: truncate.
static StringCenter STRINGMANIP_CENTER
 String manipulator: center.
static StringMove STRINGMANIP_MOVE
 String manipulator: move.
static StringAppend STRINGMANIP_APPEND
 String manipulator: append.
static StringInsert STRINGMANIP_INSERT
 String manipulator: insert.
static StringNumFormat STRINGMANIP_NUMFORMAT
 String manipulator: numformat.
static StringTranslate STRINGMANIP_TRANSLATE
 String manipulator: translate.
static StringSubstr STRINGMANIP_SUBSTR
 String manipulator: substr.
static StringLPad STRINGMANIP_LPAD
 String manipulator: lpad.
static StringRPad STRINGMANIP_RPAD
 String manipulator: rpad.
static StringSWrap STRINGMANIP_SWRAP
 String manipulator: swrap.
static StringXMLEscape STRINGMANIP_XMLESCAPE
 String manipulator: xmlescape.
static StringURLEncode STRINGMANIP_URLENCODE
 String manipulator: urlencode.

Detailed Description

String filter.

A string filter is a set of functions (manipulators) that can be applied to a string to yield another string. String manipulators may take one or more arguments, and they can be stacked. An example of a string filter expression would be:

uppercase|remove(' ')

This filter would first change the string to uppercase and then remove all spaces.

The general format of a string manipulator is:

<function> [ '(' [ (<identifier> | (<quote char> <argument> <quote char>)) [',' | <linear whitespace>]+ ]+ ')' ]+

Where <quote char> is either ' or ". String arguments should always be enclosed in quotes and multiple arguments should be separated by ','.


Constructor & Destructor Documentation

Ionflux::Tools::StringFilter::StringFilter  ) 
 

Constructor.

Construct new StringFilter object.

Ionflux::Tools::StringFilter::StringFilter const std::string &  initFilter  ) 
 

Constructor.

Construct new StringFilter object.

Parameters:
initFilter A string filter expression.

Ionflux::Tools::StringFilter::~StringFilter  )  [virtual]
 

Destructor.

Destruct StringFilter object.


Member Function Documentation

void Ionflux::Tools::StringFilter::addManipulator StringManipulator newManip,
bool  manage
[virtual]
 

Add a string manipulator.

Add a string manipulator to the set of manipulators available to this string filter. Manipulators must be added before they can be used in a filter expression. They also must be available during the whole lifetime of the string filter object.
NOTE: This is easily accomplished by allocating the string manipulator on the free store and passing 'true' as the 'manage' parameter. The string filter will then delete the string manipulator upon deconstruction.

Parameters:
newManip Pointer to a string manipulator object.
manage Whether this manipulator is managed by the filter.

std::string Ionflux::Tools::StringFilter::apply const std::string &  bytes  )  [virtual]
 

Apply filter.

Apply the filter to a string of bytes.

Parameters:
bytes A string to apply this filter to.
Returns:
The result of applying the string filter to bytes.

void Ionflux::Tools::StringFilter::clearFunctions  )  [protected, virtual]
 

Delete all functions.

Erase all parsed functions from this filter.

void Ionflux::Tools::StringFilter::clearManipulators  )  [protected, virtual]
 

Delete string manipulators.

Erase all manipulators from this filter.

Reporter & Ionflux::Tools::StringFilter::getLog  )  [virtual]
 

Get Console output/logging facility.

Returns:
The console output/logging facility used by this object.

StringManipulator * Ionflux::Tools::StringFilter::getManipulator const std::string &  manipName  )  [protected, virtual]
 

Get string manipulator by name.

Find a string manipulator of the specified name in the vector of registered manipulators.

Parameters:
manipName Name of the string manipulator.
Returns:
The string manipulator of the specified name if available, 0 otherwise.

void Ionflux::Tools::StringFilter::initManipulators  )  [protected, virtual]
 

Initialize string manipulators.

Initialize string manipulators usable by this filter.

void Ionflux::Tools::StringFilter::initTokenTypes  )  [protected, virtual]
 

Initialize token types.

Initialize the token types used for parsing filter expressions.

void Ionflux::Tools::StringFilter::parse  )  [protected, virtual]
 

Parse filter expression.

Parse the current filter expression.

void Ionflux::Tools::StringFilter::printDebugInfo  )  [virtual]
 

Print debug information.

void Ionflux::Tools::StringFilter::setFilter const std::string &  newFilter  )  [virtual]
 

Sets filter expression.

Sets the filter expression for this string filter.

Parameters:
newFilter A string filter expression.


Member Data Documentation

std::string Ionflux::Tools::StringFilter::filter [protected]
 

The filter expression.

std::vector<StringFilterFunction *> Ionflux::Tools::StringFilter::functions [protected]
 

The functions in this filter.

Ionflux::Tools::Reporter Ionflux::Tools::StringFilter::log [protected]
 

Console output/logging.

std::map<std::string, StringManipulator*> Ionflux::Tools::StringFilter::manipIndex [protected]
 

String manipulator index map.

std::vector<StringManipulatorEntry> Ionflux::Tools::StringFilter::manipulators [protected]
 

String manipulators available to this filter.

StringAppend Ionflux::Tools::StringFilter::STRINGMANIP_APPEND [static, protected]
 

String manipulator: append.

StringCenter Ionflux::Tools::StringFilter::STRINGMANIP_CENTER [static, protected]
 

String manipulator: center.

StringErase Ionflux::Tools::StringFilter::STRINGMANIP_ERASE [static, protected]
 

String manipulator: erase.

StringInsert Ionflux::Tools::StringFilter::STRINGMANIP_INSERT [static, protected]
 

String manipulator: insert.

StringLowercase Ionflux::Tools::StringFilter::STRINGMANIP_LOWERCASE [static, protected]
 

String manipulator: lowercase.

StringLPad Ionflux::Tools::StringFilter::STRINGMANIP_LPAD [static, protected]
 

String manipulator: lpad.

StringLTrim Ionflux::Tools::StringFilter::STRINGMANIP_LTRIM [static, protected]
 

String manipulator: ltrim.

StringMove Ionflux::Tools::StringFilter::STRINGMANIP_MOVE [static, protected]
 

String manipulator: move.

StringNumFormat Ionflux::Tools::StringFilter::STRINGMANIP_NUMFORMAT [static, protected]
 

String manipulator: numformat.

StringReplace Ionflux::Tools::StringFilter::STRINGMANIP_REPLACE [static, protected]
 

String manipulator: replace.

StringRPad Ionflux::Tools::StringFilter::STRINGMANIP_RPAD [static, protected]
 

String manipulator: rpad.

StringRTrim Ionflux::Tools::StringFilter::STRINGMANIP_RTRIM [static, protected]
 

String manipulator: rtrim.

StringSubstr Ionflux::Tools::StringFilter::STRINGMANIP_SUBSTR [static, protected]
 

String manipulator: substr.

StringSWrap Ionflux::Tools::StringFilter::STRINGMANIP_SWRAP [static, protected]
 

String manipulator: swrap.

StringTranslate Ionflux::Tools::StringFilter::STRINGMANIP_TRANSLATE [static, protected]
 

String manipulator: translate.

StringTrim Ionflux::Tools::StringFilter::STRINGMANIP_TRIM [static, protected]
 

String manipulator: trim.

StringTruncate Ionflux::Tools::StringFilter::STRINGMANIP_TRUNCATE [static, protected]
 

String manipulator: truncate.

StringUppercase Ionflux::Tools::StringFilter::STRINGMANIP_UPPERCASE [static, protected]
 

String manipulator: uppercase.

StringURLEncode Ionflux::Tools::StringFilter::STRINGMANIP_URLENCODE [static, protected]
 

String manipulator: urlencode.

StringXMLEscape Ionflux::Tools::StringFilter::STRINGMANIP_XMLESCAPE [static, protected]
 

String manipulator: xmlescape.

Tokenizer Ionflux::Tools::StringFilter::tok [protected]
 

Tokenizer for parsing filter expressions.

const TokenType Ionflux::Tools::StringFilter::TT_FUNC_ARG_DELIM [static]
 

Token type: Argument delimiter.

const TokenType Ionflux::Tools::StringFilter::TT_FUNC_ARG_SEP [static]
 

Initial value:

 {
    TokenType::USERTYPE_ID + 5, ",", false, 1}
Token type: Argument separator.

const TokenType Ionflux::Tools::StringFilter::TT_FUNC_BRACKET_LEFT [static]
 

Initial value:

 {
    TokenType::USERTYPE_ID + 2, "(", false, 1}
Token type: Function left bracket.

const TokenType Ionflux::Tools::StringFilter::TT_FUNC_BRACKET_RIGHT [static]
 

Initial value:

 {
    TokenType::USERTYPE_ID + 3, ")", false, 1}
Token type: Function right bracket.

const TokenType Ionflux::Tools::StringFilter::TT_FUNC_SEP [static]
 

Initial value:

 {
    TokenType::USERTYPE_ID + 1, "|", false, 1}
Token type: Function separator.


The documentation for this class was generated from the following files:
Generated on Tue Mar 14 21:09:27 2006 for Ionflux Tools Class Library (iftools) by  doxygen 1.4.6