GNU Octave 7.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-2022 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
37OCTAVE_NAMESPACE_BEGIN
38
39 class interpreter;
40
41 class OCTINTERP_API history_system
42 {
43 public:
44
46
47 history_system (const history_system&) = delete;
48
49 history_system& operator = (const history_system&) = delete;
50
51 ~history_system (void) = default;
52
53 void initialize (bool read_history_file = false);
54
55 void write_timestamp (void);
56
57 octave_value input_from_tmp_file (const octave_value_list& args,
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
70 octave_value timestamp_format_string (const octave_value_list& args,
71 int nargout);
72
73 std::string timestamp_format_string (void) const
74 {
75 return m_timestamp_format_string;
76 }
77
78 std::string timestamp_format_string (const std::string& file)
79 {
80 return set (m_timestamp_format_string, file);
81 }
82
84 do_history (const octave_value_list& args = octave_value_list (),
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
117OCTAVE_NAMESPACE_END
118
119#endif
T set(T &var, const T &new_val)
Definition: oct-hist.h:109
bool input_from_tmp_file(void) const
Definition: oct-hist.h:60
history_system(const history_system &)=delete
std::string timestamp_format_string(const std::string &file)
Definition: oct-hist.h:78
bool m_input_from_tmp_file
Definition: oct-hist.h:96
std::string timestamp_format_string(void) const
Definition: oct-hist.h:73
interpreter & m_interpreter
Definition: oct-hist.h:93
std::string m_timestamp_format_string
Definition: oct-hist.h:100
~history_system(void)=default
bool input_from_tmp_file(bool flag)
Definition: oct-hist.h:65
static void initialize(void)