Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #if !defined (octave_cmd_hist_h)
00024 #define octave_cmd_hist_h 1
00025
00026 #include <string>
00027
00028 #include "str-vec.h"
00029
00030 class
00031 OCTAVE_API
00032 command_history
00033 {
00034 protected:
00035
00036 command_history (void)
00037 : initialized (false), ignoring_additions (false), history_control (0),
00038 lines_in_file (0), lines_this_session (0), xfile (), xsize (-1) { }
00039
00040 public:
00041
00042 virtual ~command_history (void) { }
00043
00044 static void initialize (bool, const std::string&, int, const std::string&);
00045
00046 static bool is_initialized (void);
00047
00048 static void set_file (const std::string&);
00049
00050 static std::string file (void);
00051
00052 static void process_histcontrol (const std::string&);
00053
00054 static std::string histcontrol (void);
00055
00056 static void set_size (int);
00057
00058 static int size (void);
00059
00060 static void ignore_entries (bool = true);
00061
00062 static bool ignoring_entries (void);
00063
00064 static void add (const std::string&);
00065
00066 static void remove (int);
00067
00068 static int where (void);
00069
00070 static int length (void);
00071
00072 static int max_input_history (void);
00073
00074 static int base (void);
00075
00076 static int current_number (void);
00077
00078 static void stifle (int);
00079
00080 static int unstifle (void);
00081
00082 static int is_stifled (void);
00083
00084 static void set_mark (int n);
00085
00086
00087
00088
00089 static int goto_mark (void);
00090
00091 static void read (bool = true);
00092
00093 static void read (const std::string&, bool = true);
00094
00095 static void read_range (int = -1, int = -1, bool = true);
00096
00097 static void read_range (const std::string&, int = -1, int = -1,
00098 bool = true);
00099
00100 static void write (const std::string& = std::string ());
00101
00102 static void append (const std::string& = std::string ());
00103
00104 static void truncate_file (const std::string& = std::string (), int = -1);
00105
00106 static string_vector list (int = -1, bool = false);
00107
00108 static std::string get_entry (int);
00109
00110 static void replace_entry (int, const std::string&);
00111
00112 static void clean_up_and_save (const std::string& = std::string (), int = -1);
00113
00114 private:
00115
00116
00117
00118 command_history (const command_history&);
00119
00120 command_history& operator = (const command_history&);
00121
00122 static bool instance_ok (void);
00123
00124 static void make_command_history (void);
00125
00126
00127 static command_history *instance;
00128
00129 static void cleanup_instance (void) { delete instance; instance = 0; }
00130
00131 protected:
00132
00133
00134
00135
00136
00137 virtual void do_set_file (const std::string&);
00138
00139 virtual std::string do_file (void);
00140
00141 virtual void do_process_histcontrol (const std::string&);
00142
00143 virtual std::string do_histcontrol (void) const { return std::string (); }
00144
00145 virtual void do_initialize (bool, const std::string&, int, const std::string&);
00146
00147 virtual bool do_is_initialized (void) const;
00148
00149 virtual void do_set_size (int);
00150
00151 virtual int do_size (void) const;
00152
00153 virtual void do_ignore_entries (bool);
00154
00155 virtual bool do_ignoring_entries (void) const;
00156
00157 virtual void do_add (const std::string&);
00158
00159 virtual void do_remove (int);
00160
00161 virtual int do_where (void) const;
00162
00163 virtual int do_length (void) const;
00164
00165 virtual int do_max_input_history (void) const;
00166
00167 virtual int do_base (void) const;
00168
00169 virtual int do_current_number (void) const;
00170
00171 virtual void do_stifle (int);
00172
00173 virtual int do_unstifle (void);
00174
00175 virtual int do_is_stifled (void) const;
00176
00177 virtual void do_set_mark (int);
00178
00179 virtual int do_goto_mark (void);
00180
00181 virtual void do_read (const std::string&, bool);
00182
00183 virtual void do_read_range (const std::string&, int, int, bool);
00184
00185 virtual void do_write (const std::string&) const;
00186
00187 virtual void do_append (const std::string&);
00188
00189 virtual void do_truncate_file (const std::string&, int) const;
00190
00191 virtual string_vector do_list (int, bool) const;
00192
00193 virtual std::string do_get_entry (int) const;
00194
00195 virtual void do_replace_entry (int, const std::string&);
00196
00197 virtual void do_clean_up_and_save (const std::string&, int);
00198
00199 void error (int) const;
00200
00201 void error (const std::string&) const;
00202
00203
00204
00205 bool initialized;
00206
00207
00208 bool ignoring_additions;
00209
00210
00211 int history_control;
00212
00213
00214 int lines_in_file;
00215
00216
00217 int lines_this_session;
00218
00219
00220 std::string xfile;
00221
00222
00223 int xsize;
00224 };
00225
00226 #endif