summaryrefslogtreecommitdiff
path: root/src/util/exception.h
diff options
context:
space:
mode:
authorMorgan Deters <mdeters@gmail.com>2011-11-22 05:17:55 +0000
committerMorgan Deters <mdeters@gmail.com>2011-11-22 05:17:55 +0000
commit38bfb8f76514b154c9d6cc370c5cdbdb8118e66c (patch)
tree34113c0cbde85ba3a987db81922f97ec6fa15fea /src/util/exception.h
parentebba5e92588a500a7384f7337968758386db7888 (diff)
More language bindings work:
* with a patched SWIG, the ocaml bindings build correctly. ** I will provide my patch to the SWIG dev team. * fixed some class interfaces to play more nicely with SWIG. * php, perl, tcl now work; examples added. * improved binding module building and installation. Also: Stop #defining NULL ((void*) 0). This has been in cvc4_public.h for a long, long time, I forget why I added it in the first place, and it's a very, very bad idea. In C++, certain things are permitted for NULL that aren't permitted for ((void*) 0), like for instance implicit conversion to any pointer type. We didn't see an issue here (until now, when interfacing with SWIG), because GCC is usually pretty smart at working around such a broken #definition of NULL. But that's fragile. New exception-free Command architecture. Previously, some command invocations were wrapped in a try {} catch() {} and printed out an error. This is much more consistent now. Each Command invocation results in a CommandStatus. The status can be "unsupported", "error", or "success" (these are each derived classes, though, not strings, so that they can be easily printed in a language-specific way... e.g., in SMT-LIBv2, they are printed in a manner consistent with the spec, and "success" is not printed if the print-success option is off.) All Command functionality are now no-throw functions, which @cconway reports is a Good Thing for Google (where all C++ exceptions are suspect), and also I think is much cleaner than the old way in this instance. Added an --smtlib2 option that enables an "SMT-LIBv2 compliance mode"---really it just sets a few other options like strictParsing, inputLanguage, and printSuccess. In the future we might put other options into a compliance mode, or we might choose to make it the default.
Diffstat (limited to 'src/util/exception.h')
-rw-r--r--src/util/exception.h24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/util/exception.h b/src/util/exception.h
index 43a0354ca..fe01eba36 100644
--- a/src/util/exception.h
+++ b/src/util/exception.h
@@ -24,25 +24,29 @@
#include <iostream>
#include <string>
#include <sstream>
+#include <exception>
namespace CVC4 {
-class CVC4_PUBLIC Exception {
+class CVC4_PUBLIC Exception : public std::exception {
protected:
std::string d_msg;
public:
// Constructors
- Exception() : d_msg("Unknown exception") {}
- Exception(const std::string& msg) : d_msg(msg) {}
- Exception(const char* msg) : d_msg(msg) {}
+ Exception() throw() : d_msg("Unknown exception") {}
+ Exception(const std::string& msg) throw() : d_msg(msg) {}
+ Exception(const char* msg) throw() : d_msg(msg) {}
// Destructor
virtual ~Exception() throw() {}
// NON-VIRTUAL METHOD for setting and printing the error message
- void setMessage(const std::string& msg) { d_msg = msg; }
- std::string getMessage() const { return d_msg; }
+ void setMessage(const std::string& msg) throw() { d_msg = msg; }
+ std::string getMessage() const throw() { return d_msg; }
+
+ // overridden from base class std::exception
+ virtual const char* what() const throw() { return d_msg.c_str(); }
/**
* Get this exception as a string. Note that
@@ -56,7 +60,7 @@ public:
* toString(), there is no stream, so the parameters are default
* and you'll get exprs and types printed using the AST language.
*/
- std::string toString() const {
+ std::string toString() const throw() {
std::stringstream ss;
toStream(ss);
return ss.str();
@@ -67,12 +71,12 @@ public:
* a derived class, it's recommended that this method print the
* type of exception before the actual message.
*/
- virtual void toStream(std::ostream& os) const { os << d_msg; }
+ virtual void toStream(std::ostream& os) const throw() { os << d_msg; }
};/* class Exception */
-inline std::ostream& operator<<(std::ostream& os, const Exception& e) CVC4_PUBLIC;
-inline std::ostream& operator<<(std::ostream& os, const Exception& e) {
+inline std::ostream& operator<<(std::ostream& os, const Exception& e) throw() CVC4_PUBLIC;
+inline std::ostream& operator<<(std::ostream& os, const Exception& e) throw() {
e.toStream(os);
return os;
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback