Annotation of parser3/src/include/pa_exception.h, revision 1.38.2.2
1.10 paf 1: /** @file
1.11 paf 2: Parser: exception decls.
3:
1.38 paf 4: Copyright (c) 2001, 2003 ArtLebedev Group (http://www.artlebedev.com)
1.31 paf 5: Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
1.1 paf 6: */
7:
8: #ifndef PA_EXCEPTION_H
9: #define PA_EXCEPTION_H
1.36 paf 10:
1.38.2.2! paf 11: static const char* IDENT_EXCEPTION_H="$Date: 2003/01/23 15:38:05 $";
1.1 paf 12:
1.38.2.1 paf 13: //#include "pa_types.h"
14: #include "pa_pool.h"
1.14 parser 15:
1.38.2.1 paf 16: // forwards
17:
18: class String;
1.14 parser 19:
1.22 paf 20: // defines
21:
1.1 paf 22: class Exception {
23: public:
24:
1.38.2.2! paf 25: typedef object_ptr<const String> problem_source_type;
! 26:
! 27: static problem_source_type undefined_source;
! 28:
1.19 paf 29: Exception();
1.15 parser 30: Exception(
1.33 paf 31: const char *atype,
1.38.2.2! paf 32: problem_source_type aproblem_source,
1.15 parser 33: const char *comment_fmt, ...);
1.38.2.1 paf 34: Exception(const Exception& src):
35: ftype(src.ftype),
36: fproblem_source(src.fproblem_source),
37: fcomment(src.fcomment) {
38: }
39: Exception& operator =(const Exception& src) {
40: ftype=src.ftype;
41: fproblem_source=src.fproblem_source;
42: fcomment=src.fcomment;
43: return *this;
44: }
1.14 parser 45:
46: #ifdef XML
1.28 paf 47: Exception(
48: const String *aproblem_source,
49: GdomeException& exc);
1.14 parser 50: #endif
1.1 paf 51:
1.10 paf 52: /// extracts exception type
1.35 paf 53: const char *type(bool can_be_empty=false) const {
54: if(can_be_empty)
55: return ftype;
56: else
57: return ftype?ftype:"<no type>";
58: }
1.10 paf 59: /// extracts exception problem_source
1.38.2.1 paf 60: object_ptr<const String> problem_source() const; /// extracts exception comment
1.35 paf 61: const char *comment(bool can_be_empty=false) const {
1.38.2.1 paf 62: const char *result=fcomment.get()!=0 && *fcomment?fcomment.get():0;
1.35 paf 63: if(can_be_empty)
64: return result;
65: else
66: return result?result:"<no comment>";
67: }
1.1 paf 68:
69: private:
70:
1.33 paf 71: const char *ftype;
1.38.2.2! paf 72: problem_source_type fproblem_source;
1.38.2.1 paf 73: smart_ptr<char> fcomment;
1.15 parser 74:
1.1 paf 75: };
76:
77: #endif
E-mail: