Panda3D
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  */
17 INLINE GlobPattern::
18 GlobPattern(const std::string &pattern) : _pattern(pattern) {
19  _case_sensitive = true;
20 }
21 
22 /**
23  *
24  */
25 INLINE GlobPattern::
26 GlobPattern(const GlobPattern &copy) :
27  _pattern(copy._pattern),
28  _case_sensitive(copy._case_sensitive)
29 {
30 }
31 
32 /**
33  *
34  */
35 INLINE void GlobPattern::
36 operator = (const GlobPattern &copy) {
37  _pattern = copy._pattern;
38  _case_sensitive = copy._case_sensitive;
39 }
40 
41 /**
42  *
43  */
44 INLINE bool GlobPattern::
45 operator == (const GlobPattern &other) const {
46  return (_pattern == other._pattern && _case_sensitive == other._case_sensitive);
47 }
48 
49 /**
50  *
51  */
52 INLINE bool GlobPattern::
53 operator != (const GlobPattern &other) const {
54  return !operator == (other);
55 }
56 
57 /**
58  *
59  */
60 INLINE bool GlobPattern::
61 operator < (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  */
71 INLINE void GlobPattern::
72 set_pattern(const std::string &pattern) {
73  _pattern = pattern;
74 }
75 
76 /**
77  * Returns the pattern string that the GlobPattern object matches.
78  */
79 INLINE const std::string &GlobPattern::
80 get_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  */
88 INLINE void GlobPattern::
89 set_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  */
97 INLINE bool GlobPattern::
98 get_case_sensitive() const {
99  return _case_sensitive;
100 }
101 
102 /**
103  * Specifies a set of characters that are not matched by * or ?.
104  */
105 INLINE void GlobPattern::
106 set_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  */
113 INLINE const std::string &GlobPattern::
114 get_nomatch_chars() const {
115  return _nomatch_chars;
116 }
117 
118 /**
119  * Returns true if the candidate string matches the pattern, false otherwise.
120  */
121 INLINE bool GlobPattern::
122 matches(const std::string &candidate) const {
123  return matches_substr(_pattern.begin(), _pattern.end(),
124  candidate.begin(), candidate.end());
125 }
126 
127 /**
128  *
129  */
130 INLINE void GlobPattern::
131 output(std::ostream &out) const {
132  out << _pattern;
133 }
set_pattern
Changes the pattern string that the GlobPattern object matches.
Definition: globPattern.h:44
set_case_sensitive
Sets whether the match is case sensitive (true) or case insensitive (false).
Definition: globPattern.h:48
set_nomatch_chars
Specifies a set of characters that are not matched by * or ?.
Definition: globPattern.h:52
bool matches(const std::string &candidate) const
Returns true if the candidate string matches the pattern, false otherwise.
Definition: globPattern.I:122
This class can be used to test for string matches against standard Unix- shell filename globbing conv...
Definition: globPattern.h:32