GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
oct-hist.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1993-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_oct_hist_h)
27 #define octave_oct_hist_h 1
28 
29 #include "octave-config.h"
30 
31 #include <string>
32 
33 #include "cmd-hist.h"
34 
35 #include "ovl.h"
36 
38 
39 class interpreter;
40 
41 class OCTINTERP_API history_system
42 {
43 public:
44 
45  history_system (interpreter& interp);
46 
47  OCTAVE_DISABLE_CONSTRUCT_COPY_MOVE (history_system)
48 
49  ~history_system () = default;
50 
51  void initialize (bool read_history_file = false);
52 
53  void write_timestamp ();
54 
55  octave_value input_from_tmp_file (const octave_value_list& args,
56  int nargout);
57 
58  bool input_from_tmp_file () const
59  {
60  return m_input_from_tmp_file;
61  }
62 
63  bool input_from_tmp_file (bool flag)
64  {
65  return set (m_input_from_tmp_file, flag);
66  }
67 
68  octave_value timestamp_format_string (const octave_value_list& args,
69  int nargout);
70 
71  std::string timestamp_format_string () const
72  {
73  return m_timestamp_format_string;
74  }
75 
76  std::string timestamp_format_string (const std::string& file)
77  {
78  return set (m_timestamp_format_string, file);
79  }
80 
82  do_history (const octave_value_list& args = octave_value_list (),
83  int nargout = 0);
84 
85  void do_edit_history (const octave_value_list& args = octave_value_list ());
86 
87  void do_run_history (const octave_value_list& args = octave_value_list ());
88 
89 private:
90 
91  interpreter& m_interpreter;
92 
93  // TRUE means input is coming from temporary history file.
94  bool m_input_from_tmp_file;
95 
96  // The format of the timestamp marker written to the history file when
97  // Octave exits.
98  std::string m_timestamp_format_string;
99 
100  static std::string default_file ();
101 
102  static int default_size ();
103 
104  static std::string default_timestamp_format ();
105 
106  template <typename T>
107  T set (T& var, const T& new_val)
108  {
109  T old_val = var;
110  var = new_val;
111  return old_val;
112  }
113 };
114 
115 OCTAVE_END_NAMESPACE(octave)
116 
117 #endif
bool input_from_tmp_file() const
Definition: oct-hist.h:58
std::string timestamp_format_string(const std::string &file)
Definition: oct-hist.h:76
~history_system()=default
std::string timestamp_format_string() const
Definition: oct-hist.h:71
bool input_from_tmp_file(bool flag)
Definition: oct-hist.h:63
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn