CBMC
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ui_message.h
Go to the documentation of this file.
1/*******************************************************************\
2
3Module:
4
5Author: Daniel Kroening, kroening@kroening.com
6
7\*******************************************************************/
8
9
10#ifndef CPROVER_UTIL_UI_MESSAGE_H
11#define CPROVER_UTIL_UI_MESSAGE_H
12
13#include <memory>
14
15#include "message.h"
16#include "timestamper.h"
17
20
22{
23public:
24 enum class uit { PLAIN, XML_UI, JSON_UI };
25
26 ui_message_handlert(const class cmdlinet &, const std::string &program);
27
30
31 virtual ~ui_message_handlert();
32
33 virtual uit get_ui() const
34 {
35 return _ui;
36 }
37
38 virtual void flush(unsigned level) override;
39
41 {
42 PRECONDITION(json_stream!=nullptr);
43 return *json_stream;
44 }
45 void print(unsigned level, const structured_datat &data) override;
46
47protected:
48 std::unique_ptr<console_message_handlert> console_message_handler;
51 const bool always_flush;
52 std::unique_ptr<const timestampert> time;
53 std::ostream &out;
54 std::unique_ptr<json_stream_arrayt> json_stream;
55
58 uit,
59 const std::string &program,
60 const bool always_flush,
61 timestampert::clockt clock_type);
62
63 virtual void print(
64 unsigned level,
65 const std::string &message) override;
66
67 virtual void print(
68 unsigned level,
69 const std::string &message,
70 const source_locationt &location) override;
71
72 virtual void print(
73 unsigned level,
74 const xmlt &data) override;
75
76 virtual void print(
77 unsigned level,
78 const jsont &data) override;
79
80 virtual void xml_ui_msg(
81 const std::string &type,
82 const std::string &msg,
83 const source_locationt &location);
84
85 virtual void json_ui_msg(
86 const std::string &type,
87 const std::string &msg,
88 const source_locationt &location);
89
90 virtual void ui_msg(
91 const std::string &type,
92 const std::string &msg,
93 const source_locationt &location);
94
95 const char *level_string(unsigned level);
96
97 std::string command(unsigned c) const override
98 {
100 return message_handler->command(c);
101 else
102 return std::string();
103 }
104};
105
106#define OPT_FLUSH "(flush)"
107
108#define HELP_FLUSH " {y--flush} \t flush every line of output\n"
109
110#endif // CPROVER_UTIL_UI_MESSAGE_H
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
Provides methods for streaming JSON arrays.
Definition json_stream.h:93
Definition json.h:27
virtual std::string command(unsigned) const
Create an ECMA-48 SGR (Select Graphic Rendition) command.
Definition message.h:65
A way of representing nested key/value data.
clockt
Derived types of timestampert.
Definition timestamper.h:46
void print(unsigned level, const structured_datat &data) override
virtual void json_ui_msg(const std::string &type, const std::string &msg, const source_locationt &location)
const char * level_string(unsigned level)
std::string command(unsigned c) const override
Create an ECMA-48 SGR (Select Graphic Rendition) command.
Definition ui_message.h:97
virtual uit get_ui() const
Definition ui_message.h:33
std::ostream & out
Definition ui_message.h:53
ui_message_handlert(ui_message_handlert &&)=default
const bool always_flush
Definition ui_message.h:51
message_handlert * message_handler
Definition ui_message.h:49
std::unique_ptr< const timestampert > time
Definition ui_message.h:52
virtual void flush(unsigned level) override
virtual void xml_ui_msg(const std::string &type, const std::string &msg, const source_locationt &location)
std::unique_ptr< json_stream_arrayt > json_stream
Definition ui_message.h:54
virtual ~ui_message_handlert()
virtual json_stream_arrayt & get_json_stream()
Definition ui_message.h:40
virtual void ui_msg(const std::string &type, const std::string &msg, const source_locationt &location)
std::unique_ptr< console_message_handlert > console_message_handler
Definition ui_message.h:48
Definition xml.h:21
#define PRECONDITION(CONDITION)
Definition invariant.h:463
Emit timestamps.