Panda3D
Loading...
Searching...
No Matches
globPattern.I
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file globPattern.I
10 * @author drose
11 * @date 2000-05-30
12 */
13
14/**
15 *
16 */
17INLINE GlobPattern::
18GlobPattern(const std::string &pattern) : _pattern(pattern) {
19 _case_sensitive = true;
20}
21
22/**
23 *
24 */
25INLINE GlobPattern::
26GlobPattern(const GlobPattern &copy) :
27 _pattern(copy._pattern),
28 _case_sensitive(copy._case_sensitive)
29{
30}
31
32/**
33 *
34 */
35INLINE void GlobPattern::
36operator = (const GlobPattern &copy) {
37 _pattern = copy._pattern;
38 _case_sensitive = copy._case_sensitive;
39}
40
41/**
42 *
43 */
44INLINE bool GlobPattern::
45operator == (const GlobPattern &other) const {
46 return (_pattern == other._pattern && _case_sensitive == other._case_sensitive);
47}
48
49/**
50 *
51 */
52INLINE bool GlobPattern::
53operator != (const GlobPattern &other) const {
54 return !operator == (other);
55}
56
57/**
58 *
59 */
60INLINE bool GlobPattern::
61operator < (const GlobPattern &other) const {
62 if (_case_sensitive != other._case_sensitive) {
63 return (int)_case_sensitive < (int)other._case_sensitive;
64 }
65 return _pattern < other._pattern;
66}
67
68/**
69 * Changes the pattern string that the GlobPattern object matches.
70 */
71INLINE void GlobPattern::
72set_pattern(const std::string &pattern) {
73 _pattern = pattern;
74}
75
76/**
77 * Returns the pattern string that the GlobPattern object matches.
78 */
79INLINE const std::string &GlobPattern::
80get_pattern() const {
81 return _pattern;
82}
83
84/**
85 * Sets whether the match is case sensitive (true) or case insensitive
86 * (false). The default is case sensitive.
87 */
88INLINE void GlobPattern::
89set_case_sensitive(bool case_sensitive) {
90 _case_sensitive = case_sensitive;
91}
92
93/**
94 * Returns whether the match is case sensitive (true) or case insensitive
95 * (false). The default is case sensitive.
96 */
97INLINE bool GlobPattern::
98get_case_sensitive() const {
99 return _case_sensitive;
100}
101
102/**
103 * Specifies a set of characters that are not matched by * or ?.
104 */
105INLINE void GlobPattern::
106set_nomatch_chars(const std::string &nomatch_chars) {
107 _nomatch_chars = nomatch_chars;
108}
109
110/**
111 * Returns the set of characters that are not matched by * or ?.
112 */
113INLINE const std::string &GlobPattern::
114get_nomatch_chars() const {
115 return _nomatch_chars;
116}
117
118/**
119 * Returns true if the candidate string matches the pattern, false otherwise.
120 */
121INLINE bool GlobPattern::
122matches(const std::string &candidate) const {
123 return matches_substr(_pattern.begin(), _pattern.end(),
124 candidate.begin(), candidate.end());
125}
126
127/**
128 *
129 */
130INLINE void GlobPattern::
131output(std::ostream &out) const {
132 out << _pattern;
133}
This class can be used to test for string matches against standard Unix- shell filename globbing conv...
Definition globPattern.h:32
get_case_sensitive
Returns whether the match is case sensitive (true) or case insensitive (false).
Definition globPattern.h:48
set_pattern
Changes the pattern string that the GlobPattern object matches.
Definition globPattern.h:44
get_pattern
Returns the pattern string that the GlobPattern object matches.
Definition globPattern.h:44
bool matches(const std::string &candidate) const
Returns true if the candidate string matches the pattern, false otherwise.
set_nomatch_chars
Specifies a set of characters that are not matched by * or ?.
Definition globPattern.h:52
get_nomatch_chars
Returns the set of characters that are not matched by * or ?.
Definition globPattern.h:52
set_case_sensitive
Sets whether the match is case sensitive (true) or case insensitive (false).
Definition globPattern.h:48