GNU Octave  6.2.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-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_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 
37 namespace octave
38 {
39  class interpreter;
40 
42  {
43  public:
44 
45  history_system (interpreter& interp);
46 
47  history_system (const history_system&) = delete;
48 
50 
51  ~history_system (void) = default;
52 
53  void initialize (bool read_history_file = false);
54 
55  void write_timestamp (void);
56 
58  int nargout);
59 
60  bool input_from_tmp_file (void) const
61  {
62  return m_input_from_tmp_file;
63  }
64 
65  bool input_from_tmp_file (bool flag)
66  {
67  return set (m_input_from_tmp_file, flag);
68  }
69 
71  int nargout);
72 
73  std::string timestamp_format_string (void) const
74  {
76  }
77 
78  std::string timestamp_format_string (const std::string& file)
79  {
80  return set (m_timestamp_format_string, file);
81  }
82 
85  int nargout = 0);
86 
87  void do_edit_history (const octave_value_list& args = octave_value_list ());
88 
89  void do_run_history (const octave_value_list& args = octave_value_list ());
90 
91  private:
92 
94 
95  // TRUE means input is coming from temporary history file.
97 
98  // The format of the timestamp marker written to the history file when
99  // Octave exits.
101 
102  static std::string default_file (void);
103 
104  static int default_size (void);
105 
106  static std::string default_timestamp_format (void);
107 
108  template <typename T>
109  T set (T& var, const T& new_val)
110  {
111  T old_val = var;
112  var = new_val;
113  return old_val;
114  }
115  };
116 }
117 
118 #endif
interpreter & m_interpreter
Definition: oct-hist.h:93
bool input_from_tmp_file(bool flag)
Definition: oct-hist.h:65
void write_timestamp(void)
Definition: oct-hist.cc:286
std::string m_timestamp_format_string
Definition: oct-hist.h:100
void do_edit_history(const octave_value_list &args=octave_value_list())
Definition: oct-hist.cc:451
std::string timestamp_format_string(const std::string &file)
Definition: oct-hist.h:78
history_system(const history_system &)=delete
void do_run_history(const octave_value_list &args=octave_value_list())
Definition: oct-hist.cc:517
void initialize(bool read_history_file=false)
Definition: oct-hist.cc:275
~history_system(void)=default
static int default_size(void)
Definition: oct-hist.cc:554
static std::string default_timestamp_format(void)
Definition: oct-hist.cc:571
bool input_from_tmp_file(void) const
Definition: oct-hist.h:60
std::string timestamp_format_string(void) const
Definition: oct-hist.h:73
history_system(interpreter &interp)
Definition: oct-hist.cc:270
history_system & operator=(const history_system &)=delete
string_vector do_history(const octave_value_list &args=octave_value_list(), int nargout=0)
Definition: oct-hist.cc:325
T set(T &var, const T &new_val)
Definition: oct-hist.h:109
static std::string default_file(void)
Definition: oct-hist.cc:538