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 |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_oct_glob_h) |
|
24 #define octave_oct_glob_h 1 |
|
25 |
|
26 #include <string> |
|
27 |
|
28 #include "Array.h" |
|
29 #include "str-vec.h" |
|
30 |
|
31 class |
|
32 glob_match |
|
33 { |
|
34 public: |
|
35 |
|
36 enum opts |
|
37 { |
|
38 pathname = 1, // No wildcard can ever match `/'. |
|
39 noescape = 2, // Backslashes don't quote special chars. |
|
40 period = 4 // Leading `.' is matched only explicitly. |
|
41 }; |
|
42 |
|
43 glob_match (const string& p = string (), |
|
44 unsigned int f = pathname|noescape|period) |
|
45 : pat (p), flags (f) { } |
|
46 |
|
47 glob_match (const string_vector& p = string_vector (), |
|
48 unsigned int f = pathname|noescape|period) |
|
49 : pat (p), flags (f) { } |
|
50 |
|
51 glob_match (const glob_match& gm) : pat (gm.pat), flags (gm.flags) { } |
|
52 |
|
53 glob_match& operator = (const glob_match& gm) |
|
54 { |
|
55 if (this != &gm) |
|
56 { |
|
57 pat = gm.pat; |
|
58 flags = gm.flags; |
|
59 } |
|
60 return *this; |
|
61 } |
|
62 |
|
63 ~glob_match (void) { } |
|
64 |
|
65 void set_pattern (const string& p) { pat = p; } |
|
66 |
|
67 void set_pattern (const string_vector& p) { pat = p; } |
|
68 |
|
69 bool match (const string&); |
|
70 |
|
71 Array<bool> match (const string_vector&); |
|
72 |
|
73 string_vector glob (void); |
|
74 |
|
75 private: |
|
76 |
|
77 // Globbing pattern(s). |
|
78 string_vector pat; |
|
79 |
|
80 // Option flags. |
|
81 unsigned int flags; |
|
82 }; |
|
83 |
|
84 #endif |
|
85 |
|
86 /* |
|
87 ;;; Local Variables: *** |
|
88 ;;; mode: C++ *** |
|
89 ;;; End: *** |
|
90 */ |