Mercurial > octave
annotate liboctave/system/oct-env.h @ 30050:0a8c6cafd7cc
maint: use "m_" prefix for member variables in oct-env.h.
* oct-env.cc, oct-env.h: use "m_" prefix for member variables class env.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 25 Aug 2021 20:16:05 -0700 |
parents | 7854d5752dd2 |
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 //////////////////////////////////////////////////////////////////////// |
2926 | 25 |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
26 #if ! defined (octave_oct_env_h) |
17822
ebb3ef964372
maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
27 #define octave_oct_env_h 1 |
2926 | 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 |
2926 | 31 #include <string> |
32 | |
21734
11af9c03400c
write namespace keyword and name on same line in C++ files
John W. Eaton <jwe@octave.org>
parents:
21732
diff
changeset
|
33 namespace octave |
2926 | 34 { |
21734
11af9c03400c
write namespace keyword and name on same line in C++ files
John W. Eaton <jwe@octave.org>
parents:
21732
diff
changeset
|
35 namespace sys |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
36 { |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
37 class |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
38 OCTAVE_API |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
39 env |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
40 { |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
41 protected: |
2926 | 42 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
43 env (void); |
2926 | 44 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
45 public: |
2926 | 46 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
47 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
48 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
49 env (const env&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
50 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
51 env& operator = (const env&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
52 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
53 static std::string polite_directory_format (const std::string& name); |
6838 | 54 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
55 static bool absolute_pathname (const std::string& s); |
2926 | 56 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
57 static bool rooted_relative_pathname (const std::string& s); |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
58 |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
59 static std::string base_pathname (const std::string& s); |
2926 | 60 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
61 static std::string |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
62 make_absolute (const std::string& s, |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
63 const std::string& dot_path = get_current_directory ()); |
2926 | 64 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
65 static std::string get_current_directory (void); |
19458
d8fd3842a507
Use gnulib gen_tempname to create temporary names (Bug #43872).
John Donoghue <john.donoghue@ieee.org>
parents:
17822
diff
changeset
|
66 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
67 static std::string get_home_directory (void); |
2926 | 68 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
69 static std::string get_temp_directory (void); |
2926 | 70 |
27832
8fd7d1d2a4ca
Read startup files from XDG_CONFIG_HOME or LOCALAPPDATA (bug #36477).
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
71 static std::string get_user_config_directory (void); |
8fd7d1d2a4ca
Read startup files from XDG_CONFIG_HOME or LOCALAPPDATA (bug #36477).
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
72 |
28854
491433ba8612
Move history file location to inside XDG_CONFIG_HOME or APPDATA (bug #57463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
73 static std::string get_user_data_directory (void); |
491433ba8612
Move history file location to inside XDG_CONFIG_HOME or APPDATA (bug #57463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
74 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
75 static std::string get_program_name (void); |
2926 | 76 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
77 static std::string get_program_invocation_name (void); |
2926 | 78 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
79 static std::string get_user_name (void); |
2926 | 80 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
81 static std::string get_host_name (void); |
2926 | 82 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
83 static std::string getenv (const std::string& name); |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
84 |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
85 static void putenv (const std::string& name, const std::string& value); |
5489 | 86 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
87 static bool have_x11_display (void); |
2926 | 88 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
89 static bool chdir (const std::string& newdir); |
2926 | 90 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
91 static void set_program_name (const std::string& s); |
2926 | 92 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
93 private: |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
94 |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
95 static bool instance_ok (void); |
2926 | 96 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
97 std::string do_polite_directory_format (const std::string& name) const; |
2926 | 98 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
99 bool do_absolute_pathname (const std::string& s) const; |
2926 | 100 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
101 bool do_rooted_relative_pathname (const std::string& s) const; |
6838 | 102 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
103 std::string do_base_pathname (const std::string& s) const; |
2926 | 104 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
105 std::string do_make_absolute (const std::string& s, |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
106 const std::string& dot_path) const; |
2926 | 107 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
108 std::string do_getcwd (void) const; |
2926 | 109 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
110 std::string do_get_home_directory (void) const; |
2926 | 111 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
112 std::string do_get_temp_directory (void) const; |
19458
d8fd3842a507
Use gnulib gen_tempname to create temporary names (Bug #43872).
John Donoghue <john.donoghue@ieee.org>
parents:
17822
diff
changeset
|
113 |
27832
8fd7d1d2a4ca
Read startup files from XDG_CONFIG_HOME or LOCALAPPDATA (bug #36477).
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
114 std::string do_get_user_config_directory (void) const; |
8fd7d1d2a4ca
Read startup files from XDG_CONFIG_HOME or LOCALAPPDATA (bug #36477).
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
115 |
28854
491433ba8612
Move history file location to inside XDG_CONFIG_HOME or APPDATA (bug #57463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
116 std::string do_get_user_data_directory (void) const; |
491433ba8612
Move history file location to inside XDG_CONFIG_HOME or APPDATA (bug #57463).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
117 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
118 std::string do_get_user_name (void) const; |
2926 | 119 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
120 std::string do_get_host_name (void) const; |
2926 | 121 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
122 std::string do_getenv (const std::string& name) const; |
2926 | 123 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
124 void do_putenv (const std::string& name, const std::string& value) const; |
2926 | 125 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
126 bool do_chdir (const std::string& newdir); |
2926 | 127 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
128 void do_set_program_name (const std::string& s) const; |
2926 | 129 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
130 void pathname_backup (std::string& path, int n) const; |
2926 | 131 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
132 void error (int) const; |
2926 | 133 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
134 void error (const std::string&) const; |
2926 | 135 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
136 // The real thing. |
30050
0a8c6cafd7cc
maint: use "m_" prefix for member variables in oct-env.h.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
137 static env *m_instance; |
2926 | 138 |
30050
0a8c6cafd7cc
maint: use "m_" prefix for member variables in oct-env.h.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
139 static void cleanup_instance (void) |
0a8c6cafd7cc
maint: use "m_" prefix for member variables in oct-env.h.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
140 { delete m_instance; m_instance = nullptr; } |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
141 |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
142 // TRUE means follow symbolic links that point to directories just |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
143 // as if they are real directories. |
30050
0a8c6cafd7cc
maint: use "m_" prefix for member variables in oct-env.h.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
144 bool m_follow_symbolic_links; |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
145 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
146 // TRUE means that pwd always give verbatim directory, regardless |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
147 // of symbolic link following. |
30050
0a8c6cafd7cc
maint: use "m_" prefix for member variables in oct-env.h.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
148 bool m_verbatim_pwd; |
2926 | 149 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
150 // Where are we? |
30050
0a8c6cafd7cc
maint: use "m_" prefix for member variables in oct-env.h.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
151 mutable std::string m_current_directory; |
2926 | 152 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
153 // Etc. |
30050
0a8c6cafd7cc
maint: use "m_" prefix for member variables in oct-env.h.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
154 mutable std::string m_prog_name; |
2926 | 155 |
30050
0a8c6cafd7cc
maint: use "m_" prefix for member variables in oct-env.h.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
156 mutable std::string m_prog_invocation_name; |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
157 |
30050
0a8c6cafd7cc
maint: use "m_" prefix for member variables in oct-env.h.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
158 mutable std::string m_user_name; |
2926 | 159 |
30050
0a8c6cafd7cc
maint: use "m_" prefix for member variables in oct-env.h.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
160 mutable std::string m_host_name; |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
161 }; |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
162 } |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
163 } |
2926 | 164 |
165 #endif |