about summary refs log tree commit diff homepage
path: root/lib/SMT/exception.h
diff options
context:
space:
mode:
authorCristian Cadar <cristic@cs.stanford.edu>2009-06-08 07:53:36 +0000
committerCristian Cadar <cristic@cs.stanford.edu>2009-06-08 07:53:36 +0000
commit17af2a1562d9d3c0bfac8a5fa56cb622b95fbacb (patch)
tree8c9960892065589e771a7c79ecd77e6dcad2a45a /lib/SMT/exception.h
parentf992f74ff55edfbe8134eee4c5494803da8fdabc (diff)
downloadklee-17af2a1562d9d3c0bfac8a5fa56cb622b95fbacb.tar.gz
Added CVC3's parser for the SMT-LIB grammar.
git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@73059 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/SMT/exception.h')
-rw-r--r--lib/SMT/exception.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/lib/SMT/exception.h b/lib/SMT/exception.h
new file mode 100644
index 00000000..97f79669
--- /dev/null
+++ b/lib/SMT/exception.h
@@ -0,0 +1,58 @@
+/*****************************************************************************/
+/*!
+ * \file exception.h
+ * 
+ * Author: Sergey Berezin
+ * 
+ * Created: Thu Feb  6 13:09:44 2003
+ *
+ * <hr>
+ *
+ * License to use, copy, modify, sell and/or distribute this software
+ * and its documentation for any purpose is hereby granted without
+ * royalty, subject to the terms and conditions defined in the \ref
+ * LICENSE file provided with this distribution.
+ * 
+ * <hr>
+ * 
+ * A generic exception.  Any thrown exception must inherit from this
+ * class and whenever possible, set the error message.
+ */
+/*****************************************************************************/
+
+#ifndef _cvc3__exception_h_
+#define _cvc3__exception_h_
+
+#include <string>
+#include <iostream>
+
+namespace CVC3 {
+
+  class 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) { }
+    // Destructor
+    virtual ~Exception() { }
+    // NON-VIRTUAL METHODs for setting and printing the error message
+    void setMessage(const std::string& msg) { d_msg = msg; }
+    // Printing: feel free to redefine toString().  When inherited,
+    // it's recommended that this method print the type of exception
+    // before the actual message.
+    virtual std::string toString() const { return d_msg; }
+    // No need to overload operator<< for the inherited classes
+    friend std::ostream& operator<<(std::ostream& os, const Exception& e);
+
+  }; // end of class Exception
+
+  inline std::ostream& operator<<(std::ostream& os, const Exception& e) {
+    return os << e.toString();
+  }
+
+} // end of namespace CVC3 
+
+#endif