Mercurial > octave
annotate liboctave/util/pathsearch.h @ 29358:0a5b15007766 stable
update Octave Project Developers copyright for the new year
In files that have the "Octave Project Developers" copyright notice,
update for 2021.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 10 Feb 2021 09:52:15 -0500 |
parents | bd51beb6205e |
children | 796f54d4ddbf |
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 // |
29358
0a5b15007766
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
3 // Copyright (C) 1996-2021 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 //////////////////////////////////////////////////////////////////////// |
1786 | 25 |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
26 #if ! defined (octave_pathsearch_h) |
1786 | 27 #define octave_pathsearch_h 1 |
28 | |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21017
diff
changeset
|
29 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21017
diff
changeset
|
30 |
21867
0cdfd6d230e6
use std::list<std::string> instead of string_vector in pathsearch functions
John W. Eaton <jwe@octave.org>
parents:
21752
diff
changeset
|
31 #include <list> |
1786 | 32 #include <string> |
33 | |
21745
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
34 namespace octave |
1786 | 35 { |
21745
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
36 class |
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
37 OCTAVE_API |
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
38 directory_path |
8008
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
39 { |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
40 public: |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
41 |
26174
94fc8648f0fe
eliminate some unused and unnecessary path expansion code
John W. Eaton <jwe@octave.org>
parents:
25147
diff
changeset
|
42 directory_path (const std::string& s = ""); |
21745
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
43 |
24991
831389905438
omit argument name from default copy ctors and assignment operators
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
44 directory_path (const directory_path&) = default; |
21745
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
45 |
24991
831389905438
omit argument name from default copy ctors and assignment operators
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
46 directory_path& operator = (const directory_path&) = default; |
21745
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
47 |
22868
87e3163f6c87
use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
48 ~directory_path (void) = default; |
21745
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
49 |
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
50 void set (const std::string& s) |
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
51 { |
21867
0cdfd6d230e6
use std::list<std::string> instead of string_vector in pathsearch functions
John W. Eaton <jwe@octave.org>
parents:
21752
diff
changeset
|
52 m_initialized = false; |
0cdfd6d230e6
use std::list<std::string> instead of string_vector in pathsearch functions
John W. Eaton <jwe@octave.org>
parents:
21752
diff
changeset
|
53 m_orig_path = s; |
21745
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
54 init (); |
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
55 } |
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
56 |
21867
0cdfd6d230e6
use std::list<std::string> instead of string_vector in pathsearch functions
John W. Eaton <jwe@octave.org>
parents:
21752
diff
changeset
|
57 std::list<std::string> elements (void); |
0cdfd6d230e6
use std::list<std::string> instead of string_vector in pathsearch functions
John W. Eaton <jwe@octave.org>
parents:
21752
diff
changeset
|
58 |
0cdfd6d230e6
use std::list<std::string> instead of string_vector in pathsearch functions
John W. Eaton <jwe@octave.org>
parents:
21752
diff
changeset
|
59 std::list<std::string> all_directories (void); |
21745
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
60 |
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
61 std::string find_first (const std::string&); |
21867
0cdfd6d230e6
use std::list<std::string> instead of string_vector in pathsearch functions
John W. Eaton <jwe@octave.org>
parents:
21752
diff
changeset
|
62 |
21745
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
63 std::string find (const std::string& nm) { return find_first (nm); } |
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
64 |
21867
0cdfd6d230e6
use std::list<std::string> instead of string_vector in pathsearch functions
John W. Eaton <jwe@octave.org>
parents:
21752
diff
changeset
|
65 std::list<std::string> find_all (const std::string&); |
21745
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
66 |
21867
0cdfd6d230e6
use std::list<std::string> instead of string_vector in pathsearch functions
John W. Eaton <jwe@octave.org>
parents:
21752
diff
changeset
|
67 std::string find_first_of (const std::list<std::string>& names); |
0cdfd6d230e6
use std::list<std::string> instead of string_vector in pathsearch functions
John W. Eaton <jwe@octave.org>
parents:
21752
diff
changeset
|
68 |
0cdfd6d230e6
use std::list<std::string> instead of string_vector in pathsearch functions
John W. Eaton <jwe@octave.org>
parents:
21752
diff
changeset
|
69 std::list<std::string> |
0cdfd6d230e6
use std::list<std::string> instead of string_vector in pathsearch functions
John W. Eaton <jwe@octave.org>
parents:
21752
diff
changeset
|
70 find_all_first_of (const std::list<std::string>& names); |
21745
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
71 |
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
72 void rehash (void) |
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
73 { |
21867
0cdfd6d230e6
use std::list<std::string> instead of string_vector in pathsearch functions
John W. Eaton <jwe@octave.org>
parents:
21752
diff
changeset
|
74 m_initialized = false; |
21745
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
75 init (); |
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
76 } |
8008
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
77 |
23743
e919cc8d9d92
don't use singleton pattern in pathsearch class; treat pathsep as constant
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
78 static char path_sep_char (void); |
8008
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
79 |
23743
e919cc8d9d92
don't use singleton pattern in pathsearch class; treat pathsep as constant
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
80 // static void path_sep_char (char c); |
9266 | 81 |
23743
e919cc8d9d92
don't use singleton pattern in pathsearch class; treat pathsep as constant
John W. Eaton <jwe@octave.org>
parents:
23615
diff
changeset
|
82 static std::string path_sep_str (void); |
8008
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
83 |
21745
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
84 static bool is_path_sep (char c) { return c == path_sep_char (); } |
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
85 |
8008
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
86 private: |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
87 |
21745
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
88 // The colon separated list that we were given. |
21867
0cdfd6d230e6
use std::list<std::string> instead of string_vector in pathsearch functions
John W. Eaton <jwe@octave.org>
parents:
21752
diff
changeset
|
89 std::string m_orig_path; |
21745
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
90 |
21867
0cdfd6d230e6
use std::list<std::string> instead of string_vector in pathsearch functions
John W. Eaton <jwe@octave.org>
parents:
21752
diff
changeset
|
91 // TRUE means we've unpacked the path p. |
0cdfd6d230e6
use std::list<std::string> instead of string_vector in pathsearch functions
John W. Eaton <jwe@octave.org>
parents:
21752
diff
changeset
|
92 bool m_initialized; |
21745
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
93 |
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
94 // A version of the colon separate list on which we have performed |
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
95 // tilde, variable, and possibly default path expansion. |
21867
0cdfd6d230e6
use std::list<std::string> instead of string_vector in pathsearch functions
John W. Eaton <jwe@octave.org>
parents:
21752
diff
changeset
|
96 std::string m_expanded_path; |
21745
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
97 |
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
98 // The elements of the list. |
21867
0cdfd6d230e6
use std::list<std::string> instead of string_vector in pathsearch functions
John W. Eaton <jwe@octave.org>
parents:
21752
diff
changeset
|
99 std::list<std::string> m_path_elements; |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
100 |
21745
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
101 void init (void); |
8008
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
102 }; |
21745
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
103 } |
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
104 |
1786 | 105 #endif |