CVC3
2.4.1
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
src
include
exception.h
Go to the documentation of this file.
1
/*****************************************************************************/
2
/*!
3
* \file exception.h
4
*
5
* Author: Sergey Berezin
6
*
7
* Created: Thu Feb 6 13:09:44 2003
8
*
9
* <hr>
10
*
11
* License to use, copy, modify, sell and/or distribute this software
12
* and its documentation for any purpose is hereby granted without
13
* royalty, subject to the terms and conditions defined in the \ref
14
* LICENSE file provided with this distribution.
15
*
16
* <hr>
17
*
18
* A generic exception. Any thrown exception must inherit from this
19
* class and whenever possible, set the error message.
20
*/
21
/*****************************************************************************/
22
23
#ifndef _cvc3__exception_h_
24
#define _cvc3__exception_h_
25
26
#include <string>
27
#include <iostream>
28
29
namespace
CVC3 {
30
31
class
Exception
{
32
protected
:
33
std::string
d_msg
;
34
public
:
35
// Constructors
36
Exception
():
d_msg
(
"Unknown exception"
) { }
37
Exception
(
const
std::string& msg):
d_msg
(msg) { }
38
Exception
(
const
char
* msg):
d_msg
(msg) { }
39
// Destructor
40
virtual
~Exception
() { }
41
// NON-VIRTUAL METHODs for setting and printing the error message
42
void
setMessage
(
const
std::string& msg) {
d_msg
= msg; }
43
// Printing: feel free to redefine toString(). When inherited,
44
// it's recommended that this method print the type of exception
45
// before the actual message.
46
virtual
std::string
toString
()
const
{
return
d_msg
; }
47
// No need to overload operator<< for the inherited classes
48
friend
std::ostream&
operator<<
(std::ostream& os,
const
Exception
& e);
49
50
};
// end of class Exception
51
52
inline
std::ostream&
operator<<
(std::ostream& os,
const
Exception
& e) {
53
return
os << e.
toString
();
54
}
55
56
}
// end of namespace CVC3
57
58
#endif
Generated on Mon Aug 19 2013 14:42:40 for CVC3 by
1.8.4