Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

RegexPattern Class Reference

Class RegexPattern represents a compiled regular expression. More...

#include <regex.h>

Inheritance diagram for RegexPattern::

UObject UMemory List of all members.

Public Methods

 RegexPattern ()
 default constructor. More...

 RegexPattern (const RegexPattern &source)
 Copy Constructor. More...

virtual ~RegexPattern ()
 Destructor. More...

UBool operator== (const RegexPattern &that) const
 Comparison operator. More...

UBool operator!= (const RegexPattern &that) const
 Comparison operator. More...

RegexPattern & operator= (const RegexPattern &source)
 Assignment operator. More...

virtual RegexPattern * clone () const
 Create an exact copy of this RegexPattern object. More...

virtual uint32_t flags () const
 Get the match mode flags that were used when compiling this pattern. More...

virtual RegexMatchermatcher (const UnicodeString &input, UErrorCode &status) const
 Creates a RegexMatcher that will match the given input against this pattern. More...

virtual RegexMatchermatcher (UErrorCode &status) const
 Creates a RegexMatcher that will match against this pattern. More...

virtual UnicodeString pattern () const
 Returns the regular expression from which this pattern was compiled. More...

virtual int32_t split (const UnicodeString &input, UnicodeString dest[], int32_t destCapacity, UErrorCode &status) const
 Split a string into fields. More...

void dump () const
 dump Debug function, displays the compiled form of a pattern. More...

virtual UClassID getDynamicClassID () const
 ICU "poor man's RTTI", returns a UClassID for the actual class. More...


Static Public Methods

RegexPattern * compile (const UnicodeString &regex, UParseError &pe, UErrorCode &status)
 Compiles the regular expression in string form into a RegexPattern object. More...

RegexPattern * compile (const UnicodeString &regex, uint32_t flags, UParseError &pe, UErrorCode &status)
 Compiles the regular expression in string form into a RegexPattern object using the specified match mode flags. More...

RegexPattern * compile (const UnicodeString &regex, uint32_t flags, UErrorCode &status)
 Compiles the regular expression in string form into a RegexPattern object using the specified match mode flags. More...

UBool matches (const UnicodeString &regex, const UnicodeString &input, UParseError &pe, UErrorCode &status)
 Test whether a string matches a regular expression. More...

UClassID getStaticClassID ()
 ICU "poor man's RTTI", returns a UClassID for this class. More...


Private Methods

void init ()
void zap ()
void dumpOp (int32_t index) const

Private Attributes

UnicodeString fPattern
uint32_t fFlags
UVector32 * fCompiledPat
UnicodeString fLiteralText
UVector * fSets
Regex8BitSet * fSets8
UErrorCode fDeferredStatus
int32_t fMinMatchLen
int32_t fFrameSize
int32_t fDataSize
UVector32 * fGroupMap
int32_t fMaxCaptureDigits
UnicodeSet ** fStaticSets
Regex8BitSet * fStaticSets8
int32_t fStartType
int32_t fInitialStringIdx
int32_t fInitialStringLen
UnicodeSetfInitialChars
UChar32 fInitialChar
Regex8BitSet * fInitialChars8

Friends

class RegexCompile
class RegexMatcher

Detailed Description

Class RegexPattern represents a compiled regular expression.

It includes factory methods for creating a RegexPattern object from the source (string) form of a regular expression, methods for creating RegexMatchers that allow the pattern to be applied to input text, and a few convenience methods for simple common uses of regular expressions.

Class RegexPattern is not intended to be subclassed.

Draft:
This API has been introduced in ICU 2.4. It is still in draft state and may be modified in a future release.

Definition at line 109 of file regex.h.


Constructor & Destructor Documentation

RegexPattern::RegexPattern  
 

default constructor.

Create a RegexPattern object that refers to no actual pattern. Not normally needed; RegexPattern objects are usually created using the factory method compile().

Draft:
This API has been introduced in ICU 2.4. It is still in draft state and may be modified in a future release.

RegexPattern::RegexPattern const RegexPattern &    source
 

Copy Constructor.

Create a new RegexPattern object that is equivalent to the source object.

Draft:
This API has been introduced in ICU 2.4. It is still in draft state and may be modified in a future release.

virtual RegexPattern::~RegexPattern   [virtual]
 

Destructor.

Note that a RegexPattern object must persist so long as any RegexMatcher objects that were created from the RegexPattern are active.

Draft:
This API has been introduced in ICU 2.4. It is still in draft state and may be modified in a future release.


Member Function Documentation

virtual RegexPattern* RegexPattern::clone void    const [virtual]
 

Create an exact copy of this RegexPattern object.

Since RegexPattern is not intended to be subclasses, clone() and the copy construction are equivalent operations.

Returns:
the copy of this RegexPattern
Draft:
This API has been introduced in ICU 2.4. It is still in draft state and may be modified in a future release.

RegexPattern* RegexPattern::compile const UnicodeString   regex,
uint32_t    flags,
UErrorCode   status
[static]
 

Compiles the regular expression in string form into a RegexPattern object using the specified match mode flags.

These compile methods, rather than the constructors, are the usual way that RegexPattern objects are created.

Note that RegexPattern objects must not be deleted while RegexMatcher objects created from the pattern are active. RegexMatchers keep a pointer back to their pattern, so premature deletion of the pattern is a catastrophic error.

Parameters:
regex  The regular expression to be compiled.
flags  The match mode flags to be used.
status  A reference to a UErrorCode to receive any errors.
Returns:
A regexPattern object for the compiled pattern.
Draft:
This API has been introduced in ICU 2.6. It is still in draft state and may be modified in a future release.

RegexPattern* RegexPattern::compile const UnicodeString   regex,
uint32_t    flags,
UParseError   pe,
UErrorCode   status
[static]
 

Compiles the regular expression in string form into a RegexPattern object using the specified match mode flags.

These compile methods, rather than the constructors, are the usual way that RegexPattern objects are created.

Note that RegexPattern objects must not be deleted while RegexMatcher objects created from the pattern are active. RegexMatchers keep a pointer back to their pattern, so premature deletion of the pattern is a catastrophic error.

Parameters:
regex  The regular expression to be compiled.
flags  The match mode flags to be used.
pe  Receives the position (line and column nubers) of any error within the regular expression.)
status  A reference to a UErrorCode to receive any errors.
Returns:
A regexPattern object for the compiled pattern.
Draft:
This API has been introduced in ICU 2.4. It is still in draft state and may be modified in a future release.

RegexPattern* RegexPattern::compile const UnicodeString   regex,
UParseError   pe,
UErrorCode   status
[static]
 

Compiles the regular expression in string form into a RegexPattern object.

These compile methods, rather than the constructors, are the usual way that RegexPattern objects are created.

Note that RegexPattern objects must not be deleted while RegexMatcher objects created from the pattern are active. RegexMatchers keep a pointer back to their pattern, so premature deletion of the pattern is a catastrophic error.

All pattern match mode flags are set to their default values.

Parameters:
regex  The regular expression to be compiled.
pe  Receives the position (line and column nubers) of any error within the regular expression.)
status  A reference to a UErrorCode to receive any errors.
Returns:
A regexPattern object for the compiled pattern.
Draft:
This API has been introduced in ICU 2.4. It is still in draft state and may be modified in a future release.

void RegexPattern::dump   const
 

dump Debug function, displays the compiled form of a pattern.

Internal:
For internal use only.

void RegexPattern::dumpOp int32_t    index const [private]
 

virtual uint32_t RegexPattern::flags   const [virtual]
 

Get the match mode flags that were used when compiling this pattern.

Returns:
the match mode flags
Draft:
This API has been introduced in ICU 2.4. It is still in draft state and may be modified in a future release.

virtual UClassID RegexPattern::getDynamicClassID void    const [virtual]
 

ICU "poor man's RTTI", returns a UClassID for the actual class.

Draft:
This API has been introduced in ICU 2.4. It is still in draft state and may be modified in a future release.

Reimplemented from UObject.

UClassID RegexPattern::getStaticClassID void    [static]
 

ICU "poor man's RTTI", returns a UClassID for this class.

Draft:
This API has been introduced in ICU 2.4. It is still in draft state and may be modified in a future release.

void RegexPattern::init   [private]
 

virtual RegexMatcher* RegexPattern::matcher UErrorCode   status const [virtual]
 

Creates a RegexMatcher that will match against this pattern.

The RegexMatcher can be used to perform match, find or replace operations. Note that a RegexPattern object must not be deleted while RegexMatchers created from it still exist and might possibly be used again.

Parameters:
status  A reference to a UErrorCode to receive any errors.
Returns:
A RegexMatcher object for this pattern and input.
Draft:
This API has been introduced in ICU 2.6. It is still in draft state and may be modified in a future release.

virtual RegexMatcher* RegexPattern::matcher const UnicodeString   input,
UErrorCode   status
const [virtual]
 

Creates a RegexMatcher that will match the given input against this pattern.

The RegexMatcher can then be used to perform match, find or replace operations on the input. Note that a RegexPattern object must not be deleted while RegexMatchers created from it still exist and might possibly be used again.

Parameters:
input  The input string to which the regular expression will be applied.
status  A reference to a UErrorCode to receive any errors.
Returns:
A RegexMatcher object for this pattern and input.
Draft:
This API has been introduced in ICU 2.4. It is still in draft state and may be modified in a future release.

UBool RegexPattern::matches const UnicodeString   regex,
const UnicodeString   input,
UParseError   pe,
UErrorCode   status
[static]
 

Test whether a string matches a regular expression.

This convenience function both compiles the reguluar expression and applies it in a single operation. Note that if the same pattern needs to be applied repeatedly, this method will be less efficient than creating and reusing a RegexPattern object.

Parameters:
regex  The regular expression
input  The string data to be matched
pe  Receives the position of any syntax errors within the regular expression
status  A reference to a UErrorCode to receive any errors.
Returns:
True if the regular expression exactly matches the full input string.
Draft:
This API has been introduced in ICU 2.4. It is still in draft state and may be modified in a future release.

UBool RegexPattern::operator!= const RegexPattern &    that const [inline]
 

Comparison operator.

Two RegexPattern objects are considered equal if they were constructed from identical source patterns using the same match flag settings.

Parameters:
that  a RegexPattern object to compare with "this".
Returns:
TRUE if the objects are different.
Draft:
This API has been introduced in ICU 2.4. It is still in draft state and may be modified in a future release.

Definition at line 153 of file regex.h.

RegexPattern& RegexPattern::operator= const RegexPattern &    source
 

Assignment operator.

After assignment, this RegexPattern will behave identically to the source object.

Draft:
This API has been introduced in ICU 2.4. It is still in draft state and may be modified in a future release.

UBool RegexPattern::operator== const RegexPattern &    that const
 

Comparison operator.

Two RegexPattern objects are considered equal if they were constructed from identical source patterns using the same match flag settings.

Parameters:
that  a RegexPattern object to compare with "this".
Returns:
TRUE if the objects are equivalent.
Draft:
This API has been introduced in ICU 2.4. It is still in draft state and may be modified in a future release.

virtual UnicodeString RegexPattern::pattern   const [virtual]
 

Returns the regular expression from which this pattern was compiled.

Draft:
This API has been introduced in ICU 2.4. It is still in draft state and may be modified in a future release.

virtual int32_t RegexPattern::split const UnicodeString   input,
UnicodeString    dest[],
int32_t    destCapacity,
UErrorCode   status
const [virtual]
 

Split a string into fields.

Somewhat like split() from Perl. The pattern matches identify delimiters that separate the input into fields. The input data between the matches becomes the fields themselves.

For the best performance on split() operations, RegexMatcher::split is perferable to this function

Parameters:
input  The string to be split into fields. The field delimiters match the pattern (in the "this" object)
dest  An array of UnicodeStrings to receive the results of the split. This is an array of actual UnicodeString objects, not an array of pointers to strings. Local (stack based) arrays can work well here.
destCapacity  The number of elements in the destination array. If the number of fields found is less than destCapacity, the extra strings in the destination array are not altered. If the number of destination strings is less than the number of fields, the trailing part of the input string, including any field delimiters, is placed in the last destination string.
status  A reference to a UErrorCode to receive any errors.
Returns:
The number of fields into which the input string was split.
Draft:
This API has been introduced in ICU 2.4. It is still in draft state and may be modified in a future release.

void RegexPattern::zap   [private]
 


Friends And Related Function Documentation

friend class RegexCompile [friend]
 

Definition at line 409 of file regex.h.

friend class RegexMatcher [friend]
 

Definition at line 410 of file regex.h.


Member Data Documentation

UVector32* RegexPattern::fCompiledPat [private]
 

Definition at line 368 of file regex.h.

int32_t RegexPattern::fDataSize [private]
 

Definition at line 387 of file regex.h.

UErrorCode RegexPattern::fDeferredStatus [private]
 

Definition at line 376 of file regex.h.

uint32_t RegexPattern::fFlags [private]
 

Definition at line 366 of file regex.h.

int32_t RegexPattern::fFrameSize [private]
 

Definition at line 384 of file regex.h.

UVector32* RegexPattern::fGroupMap [private]
 

Definition at line 391 of file regex.h.

UChar32 RegexPattern::fInitialChar [private]
 

Definition at line 406 of file regex.h.

UnicodeSet* RegexPattern::fInitialChars [private]
 

Definition at line 405 of file regex.h.

Regex8BitSet* RegexPattern::fInitialChars8 [private]
 

Definition at line 407 of file regex.h.

int32_t RegexPattern::fInitialStringIdx [private]
 

Definition at line 403 of file regex.h.

int32_t RegexPattern::fInitialStringLen [private]
 

Definition at line 404 of file regex.h.

UnicodeString RegexPattern::fLiteralText [private]
 

Definition at line 369 of file regex.h.

int32_t RegexPattern::fMaxCaptureDigits [private]
 

Definition at line 394 of file regex.h.

int32_t RegexPattern::fMinMatchLen [private]
 

Definition at line 379 of file regex.h.

UnicodeString RegexPattern::fPattern [private]
 

Definition at line 365 of file regex.h.

UVector* RegexPattern::fSets [private]
 

Definition at line 372 of file regex.h.

Regex8BitSet* RegexPattern::fSets8 [private]
 

Definition at line 373 of file regex.h.

int32_t RegexPattern::fStartType [private]
 

Definition at line 402 of file regex.h.

UnicodeSet** RegexPattern::fStaticSets [private]
 

Definition at line 396 of file regex.h.

Regex8BitSet* RegexPattern::fStaticSets8 [private]
 

Definition at line 399 of file regex.h.


The documentation for this class was generated from the following file:
Generated on Mon Nov 24 14:36:45 2003 for ICU 2.8 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001