StringMatcher Class Reference

A utility class for doing globbing or regular expression matching. More...

#include <StringMatcher.h>

Inheritance diagram for StringMatcher:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 StringMatcher ()
 Default Constructor.
 StringMatcher (const String &matchString, bool isSimpleFormat=true)
 A constructor that sets the given expression.
 ~StringMatcher ()
 Destructor.
status_t SetPattern (const String &expression, bool isSimpleFormat=true)
 Set a new wildcard pattern or regular expression for this StringMatcher to use in future Match() calls.
const StringGetPattern () const
 Returns the pattern String as it was previously passed in to SetPattern().
bool IsPatternUnique () const
 Returns true iff this StringMatcher's pattern specifies exactly one possible string.
bool Match (const char *const matchString) const
 Returns true iff (string) is matched by the current expression.
bool Match (const String &matchString) const
 Conveneience method: Same as above, but takes a String object instead of a (const char *).
void SetNegate (bool negate)
 If set true, Match() will return the logical opposite of what it would otherwise return; e.g.
bool IsNegate () const
 Returns the current state of our negate flag.
void IncrementRefCount () const
 Increments the counter and returns true iff the new value is zero.
bool DecrementRefCount () const
 Decrements the counter and returns true iff the new value is zero.
void SetManager (AbstractObjectManager *manager)
 Sets the recycle-pointer for this object.
AbstractObjectManagerGetManager () const
 Returns this object's current recyler pointer.
uint32 GetRefCount () const
 Returns this object's current reference count.

Detailed Description

A utility class for doing globbing or regular expression matching.

(A thin wrapper around the C regex calls)

Definition at line 27 of file StringMatcher.h.


Constructor & Destructor Documentation

StringMatcher::StringMatcher ( const String matchString,
bool  isSimpleFormat = true 
)

A constructor that sets the given expression.

See SetPattern() for argument semantics.


Member Function Documentation

status_t StringMatcher::SetPattern ( const String expression,
bool  isSimpleFormat = true 
)

Set a new wildcard pattern or regular expression for this StringMatcher to use in future Match() calls.

As of v2.01, simple patterns specified here also have a special case: If you set a pattern of the form "<x-y>", where x and y are ASCII representations of positive integers, then this StringMatcher will only match ASCII representations of integers in that range. So "<19-21>" would match "19", "20", and "21" only. Also, "<-19>" will match integers less than or equal to 19, and "<21->" will match all integers greater than or equal to 21. "<->" will match everything, same as "*".

Parameters:
expression The new globbing pattern or regular expression to match with.
isSimpleFormat If you wish to use the formal regex syntax, instead of the simple syntax, set isSimpleFormat to false.
Returns:
B_NO_ERROR on success, B_ERROR on error (e.g. expression wasn't parsable, or out of memory)

bool StringMatcher::IsPatternUnique (  )  const [inline]

Returns true iff this StringMatcher's pattern specifies exactly one possible string.

(i.e. the pattern is just plain old text, with no wildcards or other pattern matching logic specified)

Definition at line 61 of file StringMatcher.h.

bool StringMatcher::Match ( const char *const  matchString  )  const

Returns true iff (string) is matched by the current expression.

Parameters:
matchString a string to match against using our current expression.
Returns:
true iff (matchString) matches, false otherwise.

Referenced by Match().

void StringMatcher::SetNegate ( bool  negate  )  [inline]

If set true, Match() will return the logical opposite of what it would otherwise return; e.g.

it will return true only when the given string doesn't match the pattern. Default state is false. Note that this flag is also set by SetPattern(..., true), based on whether or not the pattern string starts with a tilde.

Definition at line 79 of file StringMatcher.h.

void RefCountable::IncrementRefCount (  )  const [inline, inherited]

Increments the counter and returns true iff the new value is zero.

Thread safe.

Definition at line 32 of file RefCount.h.

References AtomicCounter::AtomicIncrement().

bool RefCountable::DecrementRefCount (  )  const [inline, inherited]

Decrements the counter and returns true iff the new value is zero.

Thread safe.

Definition at line 35 of file RefCount.h.

References AtomicCounter::AtomicDecrement().

void RefCountable::SetManager ( AbstractObjectManager manager  )  [inline, inherited]

Sets the recycle-pointer for this object.

If set to non-NULL, this pointer is used by the ObjectPool class to recycle this object when it is no longer in use, so as to avoid the overhead of having to delete it and re-create it later on. The RefCountable class itself does nothing with this pointer. Default value is NULL.

Parameters:
manager Pointer to the new manager object to use, or NULL to use no manager.

Definition at line 44 of file RefCount.h.

uint32 RefCountable::GetRefCount (  )  const [inline, inherited]

Returns this object's current reference count.

Note that the value returned by this method is volatile in multithreaded environments, so it may already be wrong by the time it is returned. Be careful!

Definition at line 54 of file RefCount.h.

References AtomicCounter::GetCount().


The documentation for this class was generated from the following file:
Generated on Mon Apr 28 13:59:43 2008 for MUSCLE by  doxygen 1.5.1