summaryrefslogtreecommitdiffstats
path: root/lib/antlr/antlr/ANTLRException.hpp
blob: 426595a26488236397cdf571dad558b7f2ea8062 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef INC_ANTLRException_hpp__
#define INC_ANTLRException_hpp__

/* ANTLR Translator Generator
 * Project led by Terence Parr at http://www.jGuru.com
 * Software rights: http://www.antlr.org/license.html
 *
 * $Id$
 */

#include <antlr/config.hpp>
#include <string>

#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
namespace antlr {
#endif

class ANTLR_API ANTLRException
{
public:
	/// Create ANTLR base exception without error message
	ANTLRException() : text("")
	{
	}
	/// Create ANTLR base exception with error message
	ANTLRException(const ANTLR_USE_NAMESPACE(std)string& s)
	: text(s)
	{
	}
	virtual ~ANTLRException() throw()
	{
	}

	/** Return complete error message with line/column number info (if present)
	 * @note for your own exceptions override this one. Call getMessage from
	 * here to get the 'clean' error message stored in the text attribute.
	 */
	virtual ANTLR_USE_NAMESPACE(std)string toString() const
	{
		return text;
	}

	/** Return error message without additional info (if present)
	 * @note when making your own exceptions classes override toString
	 * and call in toString getMessage which relays the text attribute
	 * from here.
	 */
	virtual ANTLR_USE_NAMESPACE(std)string getMessage() const
	{
		return text;
	}
private:
	ANTLR_USE_NAMESPACE(std)string text;
};
#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
}
#endif

#endif //INC_ANTLRException_hpp__