cprover
error.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_ERROR_H
11 #define CPROVER_UTIL_ERROR_H
12 
13 #include <exception>
14 #include <sstream>
15 
16 #include "location.h"
17 
18 class error_baset:public std::exception
19 {
20 public:
21  virtual const char* what() const throw()
22  {
23  return "";
24  }
25 
26  virtual ~error_baset() throw()
27  {
28  }
29 
31  {
32  }
33 
34  explicit error_baset(const locationt &_location):location(_location)
35  {
36  }
37 
38  locationt location;
39 };
40 
41 class error_streamt:public error_baset, public std::ostringstream
42 {
43 public:
44  virtual const char* what() const throw()
45  {
46  return str().c_str();
47  }
48 
49  virtual ~error_streamt() throw()
50  {
51  }
52 
54  {
55  }
56 
57  explicit error_streamt(const locationt &_location):
58  error_baset(_location), std::ostringstream()
59  {
60  }
61 
62  explicit error_streamt(const char *string)
63  {
64  str(string);
65  }
66 
67  explicit error_streamt(const std::string &string)
68  {
69  str(string);
70  }
71 
72  error_streamt(const error_streamt &other):std::ostringstream()
73  {
74  str(other.str());
75  location=other.location;
76  }
77 
78  error_streamt(const locationt &_location, const std::string &string):
79  error_baset(_location)
80  {
81  str(string);
82  }
83 };
84 
85 #endif // CPROVER_UTIL_ERROR_H
error_streamt(const std::string &string)
Definition: error.h:67
error_streamt()
Definition: error.h:53
error_baset(const locationt &_location)
Definition: error.h:34
STL namespace.
virtual const char * what() const
Definition: error.h:44
error_streamt(const locationt &_location)
Definition: error.h:57
virtual ~error_baset()
Definition: error.h:26
error_streamt(const char *string)
Definition: error.h:62
error_streamt(const error_streamt &other)
Definition: error.h:72
virtual ~error_streamt()
Definition: error.h:49
error_streamt(const locationt &_location, const std::string &string)
Definition: error.h:78
virtual const char * what() const
Definition: error.h:21
locationt location
Definition: error.h:38
error_baset()
Definition: error.h:30