Joedb 10.2.1
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
Command_Interpreter.h
Go to the documentation of this file.
1#ifndef joedb_Command_Interpreter_declared
2#define joedb_Command_Interpreter_declared
3
6
7#include <vector>
8#include <functional>
9#include <stdint.h>
10
11namespace joedb
12{
13 /// @ingroup ui
15 {
16 private:
17 std::vector<std::reference_wrapper<Command_Processor>> processors;
18 const Command_Interpreter *parent = nullptr;
19 std::string prompt_string = "joedbi";
20
21 bool echo = true;
22 bool rethrow = false;
23 bool prompt = false;
24 bool last_line_empty = true;
25
26 void after_command
27 (
28 std::ostream &out,
29 int64_t line_number,
30 const std::string &line,
31 const Exception *exception
32 ) const;
33
34 protected:
36 (
37 const std::string &command,
38 std::istream &parameters,
39 std::istream &in,
40 std::ostream &out
41 ) override;
42
43 public:
45 void add_processor(Command_Processor &processor);
46 void set_parent(const Command_Interpreter *new_parent);
47 void set_prompt_string(std::string s) {prompt_string = std::move(s);}
48 virtual void write_prompt(std::ostream &out) const;
49 void write_whole_prompt(std::ostream &out) const;
50 void set_echo(bool new_echo) {echo = new_echo;}
51 void set_rethrow(bool new_rethrow) {rethrow = new_rethrow;}
52 void set_prompt(bool new_prompt) {prompt = new_prompt;}
53 void main_loop(std::istream &in, std::ostream &out);
54 bool is_last_line_empty() const {return last_line_empty;}
55 };
56}
57
58#endif
void set_parent(const Command_Interpreter *new_parent)
void main_loop(std::istream &in, std::ostream &out)
void set_prompt(bool new_prompt)
void write_whole_prompt(std::ostream &out) const
void set_prompt_string(std::string s)
Status process_command(const std::string &command, std::istream &parameters, std::istream &in, std::ostream &out) override
void add_processor(Command_Processor &processor)
virtual void write_prompt(std::ostream &out) const
void set_rethrow(bool new_rethrow)