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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
50edcdd3ec22 [project @ 1997-05-03 20:21:03 by jwe]
jwe
parents:
diff changeset
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
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2924
diff changeset
27 #define octave_glob_match_h 1
2924
50edcdd3ec22 [project @ 1997-05-03 20:21:03 by jwe]
jwe
parents:
diff changeset
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
50edcdd3ec22 [project @ 1997-05-03 20:21:03 by jwe]
jwe
parents:
diff changeset
31 #include <string>
50edcdd3ec22 [project @ 1997-05-03 20:21:03 by jwe]
jwe
parents:
diff changeset
32
50edcdd3ec22 [project @ 1997-05-03 20:21:03 by jwe]
jwe
parents:
diff changeset
33 #include "Array.h"
50edcdd3ec22 [project @ 1997-05-03 20:21:03 by jwe]
jwe
parents:
diff changeset
34 #include "str-vec.h"
50edcdd3ec22 [project @ 1997-05-03 20:21:03 by jwe]
jwe
parents:
diff changeset
35
50edcdd3ec22 [project @ 1997-05-03 20:21:03 by jwe]
jwe
parents:
diff changeset
36 class
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 6095
diff changeset
37 OCTAVE_API
2924
50edcdd3ec22 [project @ 1997-05-03 20:21:03 by jwe]
jwe
parents:
diff changeset
38 glob_match
50edcdd3ec22 [project @ 1997-05-03 20:21:03 by jwe]
jwe
parents:
diff changeset
39 {
50edcdd3ec22 [project @ 1997-05-03 20:21:03 by jwe]
jwe
parents:
diff changeset
40 public:
50edcdd3ec22 [project @ 1997-05-03 20:21:03 by jwe]
jwe
parents:
diff changeset
41
50edcdd3ec22 [project @ 1997-05-03 20:21:03 by jwe]
jwe
parents:
diff changeset
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
50edcdd3ec22 [project @ 1997-05-03 20:21:03 by jwe]
jwe
parents:
diff changeset
48
6095
a8aa7a014c22 [project @ 2006-10-26 01:22:31 by jwe]
jwe
parents: 5307
diff changeset
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
50edcdd3ec22 [project @ 1997-05-03 20:21:03 by jwe]
jwe
parents:
diff changeset
53
50edcdd3ec22 [project @ 1997-05-03 20:21:03 by jwe]
jwe
parents:
diff changeset
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
50edcdd3ec22 [project @ 1997-05-03 20:21:03 by jwe]
jwe
parents:
diff changeset
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
50edcdd3ec22 [project @ 1997-05-03 20:21:03 by jwe]
jwe
parents:
diff changeset
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
50edcdd3ec22 [project @ 1997-05-03 20:21:03 by jwe]
jwe
parents:
diff changeset
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
50edcdd3ec22 [project @ 1997-05-03 20:21:03 by jwe]
jwe
parents:
diff changeset
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
50edcdd3ec22 [project @ 1997-05-03 20:21:03 by jwe]
jwe
parents:
diff changeset
68
10148
deba43069023 don't install oct-glob.h
John W. Eaton <jwe@octave.org>
parents: 10139
diff changeset
69 bool match (const std::string& str) const;
2924
50edcdd3ec22 [project @ 1997-05-03 20:21:03 by jwe]
jwe
parents:
diff changeset
70
10148
deba43069023 don't install oct-glob.h
John W. Eaton <jwe@octave.org>
parents: 10139
diff changeset
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
50edcdd3ec22 [project @ 1997-05-03 20:21:03 by jwe]
jwe
parents:
diff changeset
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
deba43069023 don't install oct-glob.h
John W. Eaton <jwe@octave.org>
parents: 10139
diff changeset
86 string_vector glob (void) const;
2924
50edcdd3ec22 [project @ 1997-05-03 20:21:03 by jwe]
jwe
parents:
diff changeset
87
50edcdd3ec22 [project @ 1997-05-03 20:21:03 by jwe]
jwe
parents:
diff changeset
88 private:
50edcdd3ec22 [project @ 1997-05-03 20:21:03 by jwe]
jwe
parents:
diff changeset
89
50edcdd3ec22 [project @ 1997-05-03 20:21:03 by jwe]
jwe
parents:
diff changeset
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
50edcdd3ec22 [project @ 1997-05-03 20:21:03 by jwe]
jwe
parents:
diff changeset
92
50edcdd3ec22 [project @ 1997-05-03 20:21:03 by jwe]
jwe
parents:
diff changeset
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
50edcdd3ec22 [project @ 1997-05-03 20:21:03 by jwe]
jwe
parents:
diff changeset
97 };
50edcdd3ec22 [project @ 1997-05-03 20:21:03 by jwe]
jwe
parents:
diff changeset
98
50edcdd3ec22 [project @ 1997-05-03 20:21:03 by jwe]
jwe
parents:
diff changeset
99 #endif