2924
|
1 /* |
|
2 |
7017
|
3 Copyright (C) 1996, 1997, 2000, 2005, 2006, 2007 John W. Eaton |
2924
|
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 |
7016
|
9 Free Software Foundation; either version 3 of the License, or (at your |
|
10 option) any later version. |
2924
|
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 |
7016
|
18 along with Octave; see the file COPYING. If not, see |
|
19 <http://www.gnu.org/licenses/>. |
2924
|
20 |
|
21 */ |
|
22 |
2926
|
23 #if !defined (octave_glob_match_h) |
|
24 #define octave_glob_match_h 1 |
2924
|
25 |
|
26 #include <string> |
|
27 |
|
28 #include "Array.h" |
|
29 #include "str-vec.h" |
|
30 |
|
31 class |
6108
|
32 OCTAVE_API |
2924
|
33 glob_match |
|
34 { |
|
35 public: |
|
36 |
|
37 enum opts |
|
38 { |
|
39 pathname = 1, // No wildcard can ever match `/'. |
|
40 noescape = 2, // Backslashes don't quote special chars. |
|
41 period = 4 // Leading `.' is matched only explicitly. |
|
42 }; |
|
43 |
6095
|
44 glob_match (const std::string& p, |
2924
|
45 unsigned int f = pathname|noescape|period) |
|
46 : pat (p), flags (f) { } |
|
47 |
|
48 glob_match (const string_vector& p = string_vector (), |
|
49 unsigned int f = pathname|noescape|period) |
|
50 : pat (p), flags (f) { } |
|
51 |
|
52 glob_match (const glob_match& gm) : pat (gm.pat), flags (gm.flags) { } |
|
53 |
|
54 glob_match& operator = (const glob_match& gm) |
|
55 { |
|
56 if (this != &gm) |
|
57 { |
|
58 pat = gm.pat; |
|
59 flags = gm.flags; |
|
60 } |
|
61 return *this; |
|
62 } |
|
63 |
|
64 ~glob_match (void) { } |
|
65 |
3504
|
66 void set_pattern (const std::string& p) { pat = p; } |
2924
|
67 |
|
68 void set_pattern (const string_vector& p) { pat = p; } |
|
69 |
3504
|
70 bool match (const std::string&); |
2924
|
71 |
|
72 Array<bool> match (const string_vector&); |
|
73 |
|
74 string_vector glob (void); |
|
75 |
|
76 private: |
|
77 |
|
78 // Globbing pattern(s). |
|
79 string_vector pat; |
|
80 |
|
81 // Option flags. |
|
82 unsigned int flags; |
|
83 }; |
|
84 |
|
85 #endif |
|
86 |
|
87 /* |
|
88 ;;; Local Variables: *** |
|
89 ;;; mode: C++ *** |
|
90 ;;; End: *** |
|
91 */ |