CBMC
typecheck.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_TYPECHECK_H
11 #define CPROVER_UTIL_TYPECHECK_H
12 
13 #include "message.h"
14 
15 class typecheckt:public messaget
16 {
17 public:
18  explicit typecheckt(message_handlert &_message_handler):
19  messaget(_message_handler)
20  {
21  }
22 
23  virtual ~typecheckt() { }
24 
25  class errort final
26  {
27  public:
28  std::string what() const
29  {
30  return message.str();
31  }
32 
33  std::ostringstream &message_ostream()
34  {
35  return message;
36  }
37 
39  {
40  __location = std::move(_location);
41  return std::move(*this);
42  }
43 
45  {
46  return __location;
47  }
48 
49  protected:
50  std::ostringstream message;
52 
53  template <typename T>
54  friend errort operator<<(errort &&e, const T &);
55  };
56 
57 protected:
58  // main function -- overload this one
59  virtual void typecheck()=0;
60 
61 public:
62  // call that one
63  virtual bool typecheck_main();
64 };
65 
67 template <typename T>
69 {
70  e.message_ostream() << message;
71  return std::move(e);
72 }
73 
74 #endif // CPROVER_UTIL_TYPECHECK_H
Class that provides messages with a built-in verbosity 'level'.
Definition: message.h:155
static const source_locationt & nil()
const source_locationt & source_location() const
Definition: typecheck.h:44
std::ostringstream message
Definition: typecheck.h:50
errort with_location(source_locationt _location) &&
Definition: typecheck.h:38
source_locationt __location
Definition: typecheck.h:51
friend errort operator<<(errort &&e, const T &)
add to the diagnostic information in the given typecheckt::errort exception
Definition: typecheck.h:68
std::ostringstream & message_ostream()
Definition: typecheck.h:33
std::string what() const
Definition: typecheck.h:28
virtual void typecheck()=0
virtual ~typecheckt()
Definition: typecheck.h:23
typecheckt(message_handlert &_message_handler)
Definition: typecheck.h:18
virtual bool typecheck_main()
Definition: typecheck.cpp:14
typecheckt::errort operator<<(typecheckt::errort &&e, const T &message)
add to the diagnostic information in the given typecheckt::errort exception
Definition: typecheck.h:68