2924
|
1 /* |
|
2 |
|
3 Copyright (C) 1996, 1997 John W. Eaton |
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
2924
|
21 |
|
22 */ |
|
23 |
2926
|
24 #if !defined (octave_glob_match_h) |
|
25 #define octave_glob_match_h 1 |
2924
|
26 |
|
27 #include <string> |
|
28 |
|
29 #include "Array.h" |
|
30 #include "str-vec.h" |
|
31 |
|
32 class |
6108
|
33 OCTAVE_API |
2924
|
34 glob_match |
|
35 { |
|
36 public: |
|
37 |
|
38 enum opts |
|
39 { |
|
40 pathname = 1, // No wildcard can ever match `/'. |
|
41 noescape = 2, // Backslashes don't quote special chars. |
|
42 period = 4 // Leading `.' is matched only explicitly. |
|
43 }; |
|
44 |
6095
|
45 glob_match (const std::string& p, |
2924
|
46 unsigned int f = pathname|noescape|period) |
|
47 : pat (p), flags (f) { } |
|
48 |
|
49 glob_match (const string_vector& p = string_vector (), |
|
50 unsigned int f = pathname|noescape|period) |
|
51 : pat (p), flags (f) { } |
|
52 |
|
53 glob_match (const glob_match& gm) : pat (gm.pat), flags (gm.flags) { } |
|
54 |
|
55 glob_match& operator = (const glob_match& gm) |
|
56 { |
|
57 if (this != &gm) |
|
58 { |
|
59 pat = gm.pat; |
|
60 flags = gm.flags; |
|
61 } |
|
62 return *this; |
|
63 } |
|
64 |
|
65 ~glob_match (void) { } |
|
66 |
3504
|
67 void set_pattern (const std::string& p) { pat = p; } |
2924
|
68 |
|
69 void set_pattern (const string_vector& p) { pat = p; } |
|
70 |
3504
|
71 bool match (const std::string&); |
2924
|
72 |
|
73 Array<bool> match (const string_vector&); |
|
74 |
|
75 string_vector glob (void); |
|
76 |
|
77 private: |
|
78 |
|
79 // Globbing pattern(s). |
|
80 string_vector pat; |
|
81 |
|
82 // Option flags. |
|
83 unsigned int flags; |
|
84 }; |
|
85 |
|
86 #endif |
|
87 |
|
88 /* |
|
89 ;;; Local Variables: *** |
|
90 ;;; mode: C++ *** |
|
91 ;;; End: *** |
|
92 */ |