Mercurial > octave
annotate liboctave/util/glob-match.h @ 31225:3eab70385569
sparse-xpow.cc: Use faster multiplication technique, this time for complex
author | Arun Giridhar <arungiridhar@gmail.com> |
---|---|
date | Sun, 11 Sep 2022 13:53:38 -0400 |
parents | 796f54d4ddbf |
children | 597f3ee61a48 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
3 // Copyright (C) 1996-2022 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
2924 | 25 |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
20232
diff
changeset
|
26 #if ! defined (octave_glob_match_h) |
2926 | 27 #define octave_glob_match_h 1 |
2924 | 28 |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
29 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
30 |
2924 | 31 #include <string> |
32 | |
33 #include "Array.h" | |
34 #include "str-vec.h" | |
35 | |
36 class | |
6108 | 37 OCTAVE_API |
2924 | 38 glob_match |
39 { | |
40 public: | |
41 | |
42 enum opts | |
10138
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
9994
diff
changeset
|
43 { |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
44 pathname = 1, // No wildcard can ever match '/'. |
10138
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
9994
diff
changeset
|
45 noescape = 2, // Backslashes don't quote special chars. |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
46 period = 4 // Leading '.' is matched only explicitly. |
10138
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
9994
diff
changeset
|
47 }; |
2924 | 48 |
6095 | 49 glob_match (const std::string& p, |
21662
5b9868c2e212
maint: Octave coding convention cleanups.
Rik <rik@octave.org>
parents:
21244
diff
changeset
|
50 unsigned int xopts = pathname | noescape | period) |
27380
72e8f15b5527
use default copy ctor and assignment op in glob and regexp classes
John W. Eaton <jwe@octave.org>
parents:
27379
diff
changeset
|
51 : m_pat (p), m_fnmatch_flags (opts_to_fnmatch_flags (xopts)) |
72e8f15b5527
use default copy ctor and assignment op in glob and regexp classes
John W. Eaton <jwe@octave.org>
parents:
27379
diff
changeset
|
52 { } |
2924 | 53 |
54 glob_match (const string_vector& p = string_vector (), | |
21662
5b9868c2e212
maint: Octave coding convention cleanups.
Rik <rik@octave.org>
parents:
21244
diff
changeset
|
55 unsigned int xopts = pathname | noescape | period) |
27380
72e8f15b5527
use default copy ctor and assignment op in glob and regexp classes
John W. Eaton <jwe@octave.org>
parents:
27379
diff
changeset
|
56 : m_pat (p), m_fnmatch_flags (opts_to_fnmatch_flags (xopts)) |
72e8f15b5527
use default copy ctor and assignment op in glob and regexp classes
John W. Eaton <jwe@octave.org>
parents:
27379
diff
changeset
|
57 { } |
2924 | 58 |
27380
72e8f15b5527
use default copy ctor and assignment op in glob and regexp classes
John W. Eaton <jwe@octave.org>
parents:
27379
diff
changeset
|
59 glob_match (const glob_match& gm) = default; |
72e8f15b5527
use default copy ctor and assignment op in glob and regexp classes
John W. Eaton <jwe@octave.org>
parents:
27379
diff
changeset
|
60 |
72e8f15b5527
use default copy ctor and assignment op in glob and regexp classes
John W. Eaton <jwe@octave.org>
parents:
27379
diff
changeset
|
61 glob_match& operator = (const glob_match& gm) = default; |
2924 | 62 |
22868
87e3163f6c87
use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
63 ~glob_match (void) = default; |
2924 | 64 |
27379
3db033e86376
use m_ prefix for data members in most liboctave/util classes
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
65 void set_pattern (const std::string& p) { m_pat = p; } |
2924 | 66 |
27379
3db033e86376
use m_ prefix for data members in most liboctave/util classes
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
67 void set_pattern (const string_vector& p) { m_pat = p; } |
2924 | 68 |
10148 | 69 bool match (const std::string& str) const; |
2924 | 70 |
10148 | 71 Array<bool> match (const string_vector& str) const |
10138
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
9994
diff
changeset
|
72 { |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
73 int n = str.numel (); |
10138
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
9994
diff
changeset
|
74 |
11570
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
75 Array<bool> retval (dim_vector (n, 1)); |
10138
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
9994
diff
changeset
|
76 |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
9994
diff
changeset
|
77 for (int i = 0; i < n; i++) |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
9994
diff
changeset
|
78 retval(i) = match (str[i]); |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
9994
diff
changeset
|
79 |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
9994
diff
changeset
|
80 return retval; |
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
9994
diff
changeset
|
81 } |
2924 | 82 |
9994
fdc3a43c0be8
avoid conflict with gnulib defining glob to be rpl_glob
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
83 // We forward to glob_internal here to avoid problems with gnulib's |
fdc3a43c0be8
avoid conflict with gnulib defining glob to be rpl_glob
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
84 // glob.h defining glob to be rpl_glob. |
fdc3a43c0be8
avoid conflict with gnulib defining glob to be rpl_glob
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
85 |
10148 | 86 string_vector glob (void) const; |
2924 | 87 |
88 private: | |
89 | |
90 // Globbing pattern(s). | |
27379
3db033e86376
use m_ prefix for data members in most liboctave/util classes
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
91 string_vector m_pat; |
2924 | 92 |
93 // Option flags. | |
27379
3db033e86376
use m_ prefix for data members in most liboctave/util classes
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
94 int m_fnmatch_flags; |
9994
fdc3a43c0be8
avoid conflict with gnulib defining glob to be rpl_glob
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
95 |
10138
805a83ecd3da
avoid conflict between glob.h definition of glob and glob_match::glob function
John W. Eaton <jwe@octave.org>
parents:
9994
diff
changeset
|
96 int opts_to_fnmatch_flags (unsigned int xopts) const; |
2924 | 97 }; |
98 | |
99 #endif |