| 1 | #ifndef INC_ANTLRException_hpp__ | 
| 2 | #define INC_ANTLRException_hpp__ | 
| 3 |  | 
| 4 | /* ANTLR Translator Generator | 
| 5 | * Project led by Terence Parr at http://www.jGuru.com | 
| 6 | * Software rights: http://www.antlr.org/license.html | 
| 7 | * | 
| 8 | * $Id$ | 
| 9 | */ | 
| 10 |  | 
| 11 | #include <antlr/config.hpp> | 
| 12 | #include <string> | 
| 13 |  | 
| 14 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE | 
| 15 | namespace antlr { | 
| 16 | #endif | 
| 17 |  | 
| 18 | class ANTLR_API ANTLRException | 
| 19 | { | 
| 20 | public: | 
| 21 | /// Create ANTLR base exception without error message | 
| 22 | ANTLRException() : text("") | 
| 23 | { | 
| 24 | } | 
| 25 | /// Create ANTLR base exception with error message | 
| 26 | ANTLRException(const ANTLR_USE_NAMESPACE(std)string& s) | 
| 27 | : text(s) | 
| 28 | { | 
| 29 | } | 
| 30 | virtual ~ANTLRException() throw() | 
| 31 | { | 
| 32 | } | 
| 33 |  | 
| 34 | /** Return complete error message with line/column number info (if present) | 
| 35 | * @note for your own exceptions override this one. Call getMessage from | 
| 36 | * here to get the 'clean' error message stored in the text attribute. | 
| 37 | */ | 
| 38 | virtual ANTLR_USE_NAMESPACE(std)string toString() const | 
| 39 | { | 
| 40 | return text; | 
| 41 | } | 
| 42 |  | 
| 43 | /** Return error message without additional info (if present) | 
| 44 | * @note when making your own exceptions classes override toString | 
| 45 | * and call in toString getMessage which relays the text attribute | 
| 46 | * from here. | 
| 47 | */ | 
| 48 | virtual ANTLR_USE_NAMESPACE(std)string getMessage() const | 
| 49 | { | 
| 50 | return text; | 
| 51 | } | 
| 52 | private: | 
| 53 | ANTLR_USE_NAMESPACE(std)string text; | 
| 54 | }; | 
| 55 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE | 
| 56 | } | 
| 57 | #endif | 
| 58 |  | 
| 59 | #endif //INC_ANTLRException_hpp__ |