Reference Manual
Inti Logo
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

Inti::G::PatternSpec Class Reference

A GPatternSpec C++ wrapper interface. More...

#include <inti/glib/pattern.h>

Inheritance diagram for Inti::G::PatternSpec:

Inti::ReferencedObject Inti::ReferencedBase List of all members.

Public Member Functions

Constructors
Accessors
Methods

Static Public Member Functions


Detailed Description

A GPatternSpec C++ wrapper interface.

A PatternSpec is the 'compiled' form of a pattern. Its match() and match_simple() methods match a string against a pattern containing '*' and '?' wildcards with similar semantics as the standard glob() function: '*' matches an arbitrary, possibly empty, string, '?' matches an arbitrary character.

Note that in contrast to glob(), the '/' character can be matched by the wildcards, there are no '[...]' character ranges and '*' and '?' can not be escaped to include them literally in a pattern.

When multiple strings must be matched against the same pattern, it is better to compile the pattern to a G::PatternSpec and use match() instead of match_simple(). This avoids the overhead of repeated pattern compilation.


Constructor & Destructor Documentation

Inti::G::PatternSpec::PatternSpec const char *  pattern  ) 
 

Constructs a PatternSpec, the compiled form of a pattern.

Parameters:
pattern A zero-terminated UTF-8 encoded string.

Inti::G::PatternSpec::PatternSpec const String pattern  ) 
 

Constructs a PatternSpec, the compiled form of a pattern.

Parameters:
pattern A UTF-8 encoded string.


Member Function Documentation

bool Inti::G::PatternSpec::equal const PatternSpec other  )  const
 

Compares this compiled pattern spec with other and returns whether they will match the same set of strings.

Parameters:
other Another PatternSpec.
Returns:
Whether the compiled patterns are equal.

bool Inti::G::PatternSpec::match const String string,
const String string_reversed
 

Matches a string against a compiled pattern.

Parameters:
string The UTF-8 encoded string to match.
string_reversed The reverse of string or null.
Returns:
true if string matches this pattern.

Note that, if the user code will (possibly) match a string against a multitude of patterns containing wildcards, chances are high that some patterns will require a reversed string. In this case, it's more efficient to provide the reversed string to avoid multiple constructions thereof in the various calls to match().

Note also that the reverse of a UTF-8 encoded string can in general not be obtained by g_strreverse(). This works only if the string doesn't contain any multibyte characters. Glib doesn't currently offer a function to reverse UTF-8 encoded strings.

bool Inti::G::PatternSpec::match const String string  ) 
 

Matches a string against a compiled pattern.

Parameters:
string The UTF-8 encoded string to match.
Returns:
true if string matches this pattern.

If the string is to be matched against more than one pattern, consider using this match() method instead while supplying the reversed string. See match(const String&, const String&) for details.

bool Inti::G::PatternSpec::match_simple const String pattern,
const String string
[static]
 

Matches a string against a pattern given as a string.

Parameters:
pattern The UTF-8 encoded pattern.
string The UTF-8 encoded string to match.
Returns:
true if string matches pspec.

If this function is to be called in a loop, it's more efficient to construct the pattern once as a PatternSpec and call match() repetitively.

bool Inti::G::PatternSpec::operator!= const PatternSpec other  )  const
 

Inequality operator; compares this compiled pattern spec with other and returns true if they will not match the same set of strings.

Parameters:
other Another PatternSpec.
Returns:
Whether the compiled patterns are not equal.

bool Inti::G::PatternSpec::operator== const PatternSpec other  )  const
 

Equality operator; compares this compiled pattern spec with other and returns true if they will match the same set of strings.

Parameters:
other Another PatternSpec.
Returns:
Whether the compiled patterns are equal.


The documentation for this class was generated from the following file: Main Page - Footer


Generated on Sun Sep 14 20:08:09 2003 for Inti by doxygen 1.3.2 written by Dimitri van Heesch, © 1997-2002