Panda3D
|
This class can be used to test for string matches against standard Unix- shell filename globbing conventions. More...
Public Member Functions | |
__init__ (const GlobPattern copy) | |
__init__ (str pattern) | |
bool | getCaseSensitive () |
Returns whether the match is case sensitive (true) or case insensitive (false). More... | |
str | getConstPrefix () |
Returns the initial part of the pattern before the first glob character. More... | |
str | getNomatchChars () |
Returns the set of characters that are not matched by * or ?. More... | |
str | getPattern () |
Returns the pattern string that the GlobPattern object matches. More... | |
bool | hasGlobCharacters () |
Returns true if the pattern includes any special globbing characters, or false if it is just a literal string. More... | |
bool | matches (str candidate) |
Returns true if the candidate string matches the pattern, false otherwise. More... | |
bool | matchesFile (Filename candidate) |
Treats the GlobPattern as a filename pattern, and returns true if the given filename matches the pattern. More... | |
object | matchFiles (const Filename cwd) |
int | matchFiles (VectorString results, const Filename cwd) |
Treats the GlobPattern as a filename pattern, and returns a list of any actual files that match the pattern. More... | |
bool | operator != (const GlobPattern other) |
bool | operator< (const GlobPattern other) |
GlobPattern | operator= (const GlobPattern copy) |
bool | operator== (const GlobPattern other) |
output (Ostream out) | |
setCaseSensitive (bool case_sensitive) | |
Sets whether the match is case sensitive (true) or case insensitive (false). More... | |
setNomatchChars (str nomatch_chars) | |
Specifies a set of characters that are not matched by * or ?. More... | |
setPattern (str pattern) | |
Changes the pattern string that the GlobPattern object matches. More... | |
Public Attributes | |
bool | case_sensitive |
Returns whether the match is case sensitive (true) or case insensitive (false). More... | |
const String | nomatch_chars |
Returns the set of characters that are not matched by * or ?. More... | |
const String | pattern |
Returns the pattern string that the GlobPattern object matches. More... | |
This class can be used to test for string matches against standard Unix- shell filename globbing conventions.
It serves as a portable standin for the Posix fnmatch() call.
A GlobPattern is given a pattern string, which can contain operators like *, ?, and []. Then it can be tested against any number of candidate strings; for each candidate, it will indicate whether the string matches the pattern or not. It can be used, for example, to scan a directory for all files matching a particular pattern.
__init__ | ( | const GlobPattern | copy | ) |
__init__ | ( | str | pattern | ) |
bool getCaseSensitive | ( | ) |
Returns whether the match is case sensitive (true) or case insensitive (false).
The default is case sensitive.
str getConstPrefix | ( | ) |
Returns the initial part of the pattern before the first glob character.
Since many glob patterns begin with a sequence of static characters and end with one or more glob characters, this can be used to optimized searches through sorted indices.
str getNomatchChars | ( | ) |
Returns the set of characters that are not matched by * or ?.
str getPattern | ( | ) |
Returns the pattern string that the GlobPattern object matches.
bool hasGlobCharacters | ( | ) |
Returns true if the pattern includes any special globbing characters, or false if it is just a literal string.
bool matches | ( | str | candidate | ) |
Returns true if the candidate string matches the pattern, false otherwise.
bool matchesFile | ( | Filename | candidate | ) |
Treats the GlobPattern as a filename pattern, and returns true if the given filename matches the pattern.
Unlike matches(), this will not match slash characters for single asterisk characters, and it will ignore path components that only contain a dot.
object matchFiles | ( | const Filename | cwd | ) |
int matchFiles | ( | VectorString | results, |
const Filename | cwd | ||
) |
Treats the GlobPattern as a filename pattern, and returns a list of any actual files that match the pattern.
This is the behavior of the standard Posix glob() function. Any part of the filename may contain glob characters, including intermediate directory names.
If cwd is specified, it is the directory that relative filenames are taken to be relative to; otherwise, the actual current working directory is assumed.
The return value is the number of files matched, which are added to the results vector.
bool operator != | ( | const GlobPattern | other | ) |
bool operator< | ( | const GlobPattern | other | ) |
GlobPattern operator= | ( | const GlobPattern | copy | ) |
bool operator== | ( | const GlobPattern | other | ) |
output | ( | Ostream | out | ) |
setCaseSensitive | ( | bool | case_sensitive | ) |
Sets whether the match is case sensitive (true) or case insensitive (false).
The default is case sensitive.
setNomatchChars | ( | str | nomatch_chars | ) |
Specifies a set of characters that are not matched by * or ?.
setPattern | ( | str | pattern | ) |
Changes the pattern string that the GlobPattern object matches.
bool case_sensitive |
Returns whether the match is case sensitive (true) or case insensitive (false).
The default is case sensitive.
const String nomatch_chars |
Returns the set of characters that are not matched by * or ?.
const String pattern |
Returns the pattern string that the GlobPattern object matches.