GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
oct-env.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2013 John W. Eaton
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
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
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
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if !defined (octave_oct_env_h)
24 #define octave_oct_env_h 1
25 
26 #include <string>
27 
28 class
29 OCTAVE_API
31 {
32 protected:
33 
34  octave_env (void);
35 
36 public:
37 
38  static std::string polite_directory_format (const std::string& name);
39 
40  static bool absolute_pathname (const std::string& s);
41 
42  static bool rooted_relative_pathname (const std::string& s);
43 
44  static std::string base_pathname (const std::string& s);
45 
46  static std::string
47  make_absolute (const std::string& s,
48  const std::string& dot_path = get_current_directory ());
49 
50  static std::string get_current_directory (void);
51 
52  static std::string get_home_directory (void);
53 
54  static std::string get_program_name (void);
55 
56  static std::string get_program_invocation_name (void);
57 
58  static std::string get_user_name (void);
59 
60  static std::string get_host_name (void);
61 
62  static std::string getenv (const std::string& name);
63 
64  static void putenv (const std::string& name, const std::string& value);
65 
66  static bool have_x11_display (void);
67 
68  static bool chdir (const std::string& newdir);
69 
70  static void set_program_name (const std::string& s);
71 
72 private:
73 
74  static bool instance_ok (void);
75 
76  std::string do_polite_directory_format (const std::string& name) const;
77 
78  bool do_absolute_pathname (const std::string& s) const;
79 
80  bool do_rooted_relative_pathname (const std::string& s) const;
81 
82  std::string do_base_pathname (const std::string& s) const;
83 
84  std::string do_make_absolute (const std::string& s,
85  const std::string& dot_path) const;
86 
87  std::string do_getcwd (void) const;
88 
89  std::string do_get_home_directory (void) const;
90 
91  std::string do_get_user_name (void) const;
92 
93  std::string do_get_host_name (void) const;
94 
95  std::string do_getenv (const std::string& name) const;
96 
97  void do_putenv (const std::string& name, const std::string& value) const;
98 
99  bool do_chdir (const std::string& newdir);
100 
101  void do_set_program_name (const std::string& s) const;
102 
103  void pathname_backup (std::string& path, int n) const;
104 
105  void error (int) const;
106 
107  void error (const std::string&) const;
108 
109  // No copying!
110 
111  octave_env (const octave_env&);
112 
113  octave_env& operator = (const octave_env&);
114 
115  // The real thing.
117 
118 
119  static void cleanup_instance (void) { delete instance; instance = 0; }
120 
121  // TRUE means follow symbolic links that point to directories just
122  // as if they are real directories.
124 
125  // TRUE means that pwd always give verbatim directory, regardless
126  // of symbolic link following.
128 
129  // Where are we?
130  mutable std::string current_directory;
131 
132  // Etc.
133  mutable std::string prog_name;
134 
135  mutable std::string prog_invocation_name;
136 
137  mutable std::string user_name;
138 
139  mutable std::string host_name;
140 };
141 
142 #endif