Mercurial > hg > octave-lyh
annotate liboctave/pathsearch.h @ 15234:ffa0b85a87f4
pt-jit.cc (jit_info::compile): Fix compile error with OCTAVE_JIT_DEBUG defined
author | Max Brister <max@2bass.com> |
---|---|
date | Sat, 25 Aug 2012 15:52:45 -0600 |
parents | 72c96de7a403 |
children |
rev | line source |
---|---|
1786 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
3 Copyright (C) 1996-2012 John W. Eaton |
1786 | 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 | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
1786 | 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 | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
1786 | 20 |
21 */ | |
22 | |
23 #if !defined (octave_pathsearch_h) | |
24 #define octave_pathsearch_h 1 | |
25 | |
26 #include <string> | |
27 | |
28 #include "str-vec.h" | |
29 | |
30 class | |
6108 | 31 OCTAVE_API |
1786 | 32 dir_path |
33 { | |
34 public: | |
35 | |
3504 | 36 dir_path (const std::string& s = std::string (), |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
37 const std::string& d = std::string ()) |
11501
331fcc41ca23
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10312
diff
changeset
|
38 : p_orig (s), p_default (d), initialized (false), p (), pv () |
1786 | 39 { |
3174 | 40 if (! p_orig.empty ()) |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
41 init (); |
1786 | 42 } |
43 | |
44 dir_path (const dir_path& dp) | |
3196 | 45 : p_orig (dp.p_orig), p_default (dp.p_default), |
46 initialized (dp.initialized), p (dp.p), pv (dp.pv) | |
3174 | 47 { } |
1786 | 48 |
49 dir_path& operator = (const dir_path& dp) | |
50 { | |
3174 | 51 p_orig = dp.p_orig; |
3196 | 52 p_default = dp.p_default; |
3174 | 53 initialized = dp.initialized; |
1786 | 54 p = dp.p; |
55 pv = dp.pv; | |
56 return *this; | |
57 } | |
58 | |
59 ~dir_path (void) { } | |
60 | |
3504 | 61 void set (const std::string& s) |
1786 | 62 { |
63 initialized = false; | |
3174 | 64 p_orig = s; |
1786 | 65 init (); |
66 } | |
67 | |
68 string_vector elements (void); | |
69 string_vector all_directories (void); | |
70 | |
3504 | 71 std::string find_first (const std::string&); |
72 std::string find (const std::string& nm) { return find_first (nm); } | |
1786 | 73 |
3504 | 74 string_vector find_all (const std::string&); |
1786 | 75 |
4242 | 76 std::string find_first_of (const string_vector& names); |
77 string_vector find_all_first_of (const string_vector& names); | |
78 | |
3185 | 79 void rehash (void) |
80 { | |
81 initialized = false; | |
82 init (); | |
83 } | |
84 | |
8010 | 85 static char path_sep_char (void) |
86 { | |
87 return static_members::path_sep_char (); | |
88 } | |
89 | |
9266 | 90 static void path_sep_char (char c) |
91 { | |
92 static_members::path_sep_char (c); | |
93 } | |
94 | |
8010 | 95 static std::string path_sep_str (void) |
96 { | |
97 return static_members::path_sep_str (); | |
98 } | |
99 | |
100 static bool is_path_sep (char c) { return c == path_sep_char (); } | |
101 | |
8008
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
102 private: |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
103 |
8010 | 104 // The colon separated list that we were given. |
105 std::string p_orig; | |
106 | |
107 // The default path. If specified, replaces leading, trailing, or | |
108 // doubled colons in p_orig. | |
109 std::string p_default; | |
110 | |
111 // TRUE means we've unpacked p. | |
112 bool initialized; | |
113 | |
114 // A version of the colon separate list on which we have performed | |
115 // tilde, variable, and possibly default path expansion. | |
116 std::string p; | |
117 | |
118 // The elements of the list. | |
119 string_vector pv; | |
120 | |
121 void init (void); | |
122 | |
8008
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
123 // Use a singleton class for these data members instead of just |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
124 // making them static members of the dir_path class so that we can |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
125 // ensure proper initialization. |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
126 |
9402
cdfb9ad48080
Add exported symbols
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9266
diff
changeset
|
127 class OCTAVE_API static_members |
8008
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
128 { |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
129 public: |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
130 |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
131 static_members (void); |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
132 |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
133 static char path_sep_char (void) |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
134 { |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
135 return instance_ok () ? instance->xpath_sep_char : 0; |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
136 } |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
137 |
9266 | 138 static void path_sep_char (char c) |
139 { | |
140 if (instance_ok ()) | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
141 { |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
142 instance->xpath_sep_char = c; |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
143 instance->xpath_sep_str = std::string (1, c); |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
144 } |
9266 | 145 } |
146 | |
8008
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
147 static std::string path_sep_str (void) |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
148 { |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
149 return instance_ok () ? instance->xpath_sep_str : std::string (); |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
150 } |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
151 |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
152 private: |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
153 |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
154 static static_members *instance; |
5777 | 155 |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
156 static void cleanup_instance (void) { delete instance; instance = 0; } |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
157 |
8008
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
158 static bool instance_ok (void); |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
159 |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
160 // No copying! |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
161 |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
162 static_members (const static_members&); |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
163 |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
164 static_members& operator = (const static_members&); |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
165 |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
166 char xpath_sep_char; |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
167 |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
168 std::string xpath_sep_str; |
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
169 }; |
1786 | 170 }; |
171 | |
172 #endif |