cprover
cout_message.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module:
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
9 
10 #ifndef CPROVER_UTIL_COUT_MESSAGE_H
11 #define CPROVER_UTIL_COUT_MESSAGE_H
12 
13 #include "message.h"
14 
16 {
17 public:
18  // all messages go to stdout
20 };
21 
23 {
24 public:
25  // all messages go to stderr
27 };
28 
30 {
31 public:
32  void print(unsigned, const xmlt &) override
33  {
34  }
35 
36  void print(unsigned, const jsont &) override
37  {
38  }
39 
40  // level 4 and upwards go to cout, level 1-3 to cerr
41  virtual void print(
42  unsigned level,
43  const std::string &message) override;
44 
45  virtual void flush(unsigned level) override;
46 
48  {
49  }
50 
52 
53  std::string command(unsigned c) const override;
54 
55 protected:
56  const bool always_flush;
57 
59  bool is_a_tty;
60 
62  bool use_SGR;
63 };
64 
66 {
67 public:
68  void print(unsigned, const xmlt &) override
69  {
70  }
71 
72  void print(unsigned, const jsont &) override
73  {
74  }
75 
76  // aims to imitate the messages gcc prints
77  virtual void print(
78  unsigned level,
79  const std::string &message) override;
80 
81  virtual void print(
82  unsigned level,
83  const std::string &message,
84  const source_locationt &location) override;
85 
86 private:
88  std::string string(const messaget::commandt &c) const
89  {
90  return command(c.command);
91  }
92 };
93 
94 #endif // CPROVER_UTIL_COUT_MESSAGE_H
Definition: json.h:23
void print(unsigned, const xmlt &) override
Definition: cout_message.h:68
void print(unsigned, const jsont &) override
Definition: cout_message.h:72
bool use_SGR
true if we use ECMA-48 SGR to render colors
Definition: cout_message.h:62
bool is_a_tty
true if we are outputting to a proper console
Definition: cout_message.h:59
void print(unsigned, const jsont &) override
Definition: cout_message.h:36
virtual void flush(unsigned level) override
std::string command(unsigned c) const override
Create an ECMA-48 SGR (Select Graphic Rendition) command with given code.
Definition: xml.h:18
unsigned command
Definition: message.h:310
void print(unsigned, const xmlt &) override
Definition: cout_message.h:32
std::string string(const messaget::commandt &c) const
feed a command into a string
Definition: cout_message.h:88