Mercurial > hg > octave-nkf
annotate liboctave/regex-match.h @ 11542:695141f1c05c ss-3-3-55
snapshot 3.3.55
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 15 Jan 2011 04:53:04 -0500 |
parents | fd0a3ac60b0e |
children | 12df7854fa7c |
rev | line source |
---|---|
7779
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
1 /* |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
2 |
11523 | 3 Copyright (C) 2008-2011 David Bateman |
7779
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
4 |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
5 This file is part of Octave. |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
6 |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
7 Octave is free software; you can redistribute it and/or modify it |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
8 under the terms of the GNU General Public License as published by the |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
9 Free Software Foundation; either version 3 of the License, or (at your |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
10 option) any later version. |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
11 |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
15 for more details. |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
16 |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
19 <http://www.gnu.org/licenses/>. |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
20 |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
21 */ |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
22 |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
23 #if !defined (octave_regex_match_h) |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
24 #define octave_regex_match_h 1 |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
25 |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
26 #include <string> |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
27 |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
28 #if defined (HAVE_REGEX) |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
29 #if defined (__MINGW32__) |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
30 #define __restrict |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
31 #endif |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
32 #include <sys/types.h> |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
33 #include <regex.h> |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
34 #endif |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
35 |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
36 #include "Array.h" |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
37 #include "str-vec.h" |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
38 |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
39 class |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
40 OCTAVE_API |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
41 regex_match |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
42 { |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
43 public: |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
44 |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
45 regex_match (const std::string& p, bool insen = false) |
11501
331fcc41ca23
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
46 : pat (p), case_insen (insen) |
331fcc41ca23
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
47 #if HAVE_REGEX |
331fcc41ca23
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
48 , compiled (0) |
331fcc41ca23
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
49 #endif |
331fcc41ca23
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
50 { |
331fcc41ca23
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
51 init (); |
331fcc41ca23
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
52 } |
7779
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
53 |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
54 regex_match (const string_vector& p = string_vector (), bool insen = false) |
11501
331fcc41ca23
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
55 : pat (p), case_insen (insen) |
331fcc41ca23
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
56 #if HAVE_REGEX |
331fcc41ca23
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
57 , compiled (0) |
331fcc41ca23
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
58 #endif |
331fcc41ca23
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
59 { |
331fcc41ca23
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
60 init (); |
331fcc41ca23
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
61 } |
7779
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
62 |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
63 regex_match (const regex_match& gm) |
11501
331fcc41ca23
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
64 : pat (gm.pat), case_insen (gm.case_insen) |
331fcc41ca23
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
65 #if HAVE_REGEX |
331fcc41ca23
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
66 , compiled (0) |
331fcc41ca23
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
67 #endif |
331fcc41ca23
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
68 { |
331fcc41ca23
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
69 init (); |
331fcc41ca23
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
70 } |
7779
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
71 |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
72 regex_match& operator = (const regex_match& gm); |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
73 |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
74 ~regex_match (void); |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
75 |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
76 void set_pattern (const std::string& p); |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
77 |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
78 void set_pattern (const string_vector& p); |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
79 |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
80 bool match (const std::string&); |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
81 |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
82 Array<bool> match (const string_vector&); |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
83 |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
84 private: |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
85 |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
86 void init (void); |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
87 |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
88 // Regex pattern(s). |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
89 string_vector pat; |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
90 |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
91 // Should match be case insensitive |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
92 bool case_insen; |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
93 |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
94 #if HAVE_REGEX |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
95 regex_t *compiled; |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
96 #endif |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
97 }; |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
98 |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
99 #endif |