NAME
OTC_Globex -
Class to perform shell style globbing on a string.
SYNOPSIS
#include <OTC/text/globex.hh>
class OTC_Globex : public OTC_Pattern
{
public:
static os_typespec* get_os_typespec();
~OTC_Globex();
OTC_Globex(char const* thePattern);
OTC_Boolean match(char const* theString);
u_int start() const;
u_int length() const;
OTC_Boolean isValid() const;
char const* error() const;
protected:
int doMatch(char const* thePattern, char const* theString);
int doMatchStar(char const* thePattern, char const* theString);
void compile();
};
CLASS TYPE
Concrete
DESCRIPTION
This class provides the ability to determine if a string
matches a particular pattern. The pattern in this case is
in the form of a shell style globbing pattern.
INITIALISATION
OTC_Globex(char const* thePattern);
MATCHING
OTC_Boolean match(char const* theString);
Returns OTCLIB_TRUE if the pattern matched
against theString
u_int start() const;
Returns the index of the first character
of the matched portion of the string.
For this class this will always return
0.
u_int length() const;
Returns the length of the matched portion
of the string. For this class this will
always return 0 or the length of the
string matched against if the match was
successful.
ERRORS
OTC_Boolean isValid() const;
Returns OTCLIB_TRUE if the pattern was
valid.
char const* error() const;
If the pattern was not valid, returns a
messages describing what was wrong with
the pattern.
COMPILATION
void compile();
FORMAT
In the pattern string:
`*' matches any sequence of characters
`?' matches any character
[SET] matches any character in the specified set,
[!SET] or [^SET] matches any character not in the specified set.
Note: the standard regex character '+' (one or more) should by
simulated by using "?*" which is equivalent here.
A set is composed of characters or ranges; a range looks like
character hyphen character (as in 0-9 or A-Z). [0-9a-zA-Z_] is the
minimal set of characters allowed in the [..] pattern construct.
To suppress the special syntactic significance of any of
`[]*?!^-\\', and match the character exactly, precede it with a
`\\'.
SOURCE
This class is based on public domain routines written by
J. Kercheval (johnk@wrq.com) and posted to alt.sources.
SEE ALSO
OTC_Pattern
LIBRARY
OTC
AUTHOR(S)
Graham Dumpleton
COPYRIGHT
Copyright 1991 OTC LIMITED
Copyright 1994 DUMPLETON SOFTWARE CONSULTING PTY LIMITED