GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
environment.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2017-2024 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_environment_h)
27 #define octave_environment_h 1
28 
29 #include "octave-config.h"
30 
31 #include <string>
32 
33 class octave_value;
34 class octave_value_list;
35 
37 
39 {
40 public:
41 
43  : m_editor (init_editor ()),
44  m_exec_path (init_exec_path ()),
45  m_image_path (init_image_path ())
46  { }
47 
48  OCTAVE_DEFAULT_COPY_DELETE (environment)
49 
50  octave_value editor (const octave_value_list& args, int nargout);
51 
52  std::string editor () const { return m_editor; }
53 
54  std::string editor (const std::string& ed)
55  {
56  return set (m_editor, ed);
57  }
58 
59  octave_value exec_path (const octave_value_list& args, int nargout);
60 
61  std::string exec_path () const { return m_exec_path; }
62 
63  std::string exec_path (const std::string& path);
64 
65  octave_value image_path (const octave_value_list& args, int nargout);
66 
67  std::string image_path () const { return m_image_path; }
68 
69  std::string image_path (const std::string& path)
70  {
71  return set (m_image_path, path);
72  }
73 
74 private:
75 
76  std::string m_editor;
77 
78  std::string m_exec_path;
79 
80  std::string m_image_path;
81 
82  static std::string init_editor ();
83 
84  static std::string init_exec_path ();
85 
86  static std::string init_image_path ();
87 
88  std::string set (std::string& var, const std::string& new_val)
89  {
90  std::string old_val = var;
91  var = new_val;
92  return old_val;
93  }
94 };
95 
96 OCTAVE_END_NAMESPACE(octave)
97 
98 #endif
std::string exec_path() const
Definition: environment.h:61
std::string image_path() const
Definition: environment.h:67
std::string editor(const std::string &ed)
Definition: environment.h:54
std::string editor() const
Definition: environment.h:52
std::string image_path(const std::string &path)
Definition: environment.h:69
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn