Joedb 10.4.3
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 <functional>
8#include <stdint.h>
9#include <vector>
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 int recursion_depth = 0;
27
28 void after_command
29 (
30 std::ostream &out,
31 int64_t line_number,
32 std::string_view line,
33 const Exception *exception
34 ) const;
35
36 protected:
38 (
39 std::string_view command,
40 std::istream &parameters,
41 std::istream &in,
42 std::ostream &out
43 ) override;
44
45 public:
47 void add_processor(Command_Processor &processor);
48 void set_parent(const Command_Interpreter *new_parent);
49 void set_prompt_string(std::string s) {prompt_string = std::move(s);}
50 virtual void write_prompt(std::ostream &out) const;
51 void write_whole_prompt(std::ostream &out) const;
52 void set_echo(bool new_echo) {echo = new_echo;}
53 void set_rethrow(bool new_rethrow) {rethrow = new_rethrow;}
54 void set_prompt(bool new_prompt) {prompt = new_prompt;}
55 void main_loop(std::istream &in, std::ostream &out);
56 bool is_last_line_empty() const {return last_line_empty;}
57 };
58}
59
60#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)
void add_processor(Command_Processor &processor)
virtual void write_prompt(std::ostream &out) const
void set_rethrow(bool new_rethrow)
Status process_command(std::string_view command, std::istream &parameters, std::istream &in, std::ostream &out) override