GNU Octave  6.2.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-2021 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 
36 namespace octave
37 {
39  {
40  public:
41 
42  environment (void)
43  : m_editor (init_editor ()),
46  { }
47 
48  octave_value editor (const octave_value_list& args, int nargout);
49 
50  std::string editor (void) const { return m_editor; }
51 
52  std::string editor (const std::string& ed)
53  {
54  return set (m_editor, ed);
55  }
56 
57  octave_value exec_path (const octave_value_list& args, int nargout);
58 
59  std::string exec_path (void) const { return m_exec_path; }
60 
61  std::string exec_path (const std::string& path);
62 
63  octave_value image_path (const octave_value_list& args, int nargout);
64 
65  std::string image_path (void) const { return m_image_path; }
66 
67  std::string image_path (const std::string& path)
68  {
69  return set (m_image_path, path);
70  }
71 
72  private:
73 
74  std::string m_editor;
75 
76  std::string m_exec_path;
77 
78  std::string m_image_path;
79 
80  static std::string init_editor (void);
81 
82  static std::string init_exec_path (void);
83 
84  static std::string init_image_path (void);
85 
86  std::string set (std::string& var, const std::string& new_val)
87  {
88  std::string old_val = var;
89  var = new_val;
90  return old_val;
91  }
92  };
93 }
94 
95 #endif
std::string image_path(const std::string &path)
Definition: environment.h:67
std::string exec_path(void) const
Definition: environment.h:59
std::string set(std::string &var, const std::string &new_val)
Definition: environment.h:86
std::string editor(const std::string &ed)
Definition: environment.h:52
static std::string init_editor(void)
Definition: environment.cc:107
static std::string init_image_path(void)
Definition: environment.cc:137
std::string m_exec_path
Definition: environment.h:76
std::string m_editor
Definition: environment.h:74
static std::string init_exec_path(void)
Definition: environment.cc:119
std::string image_path(void) const
Definition: environment.h:65
std::string m_image_path
Definition: environment.h:78
std::string editor(void) const
Definition: environment.h:50
QString path