Annotation of parser3/src/include/pa_exception.h, revision 1.8

1.1       paf         1: /*
1.6       paf         2:        Parser
                      3:        Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
1.7       paf         4:        Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
1.6       paf         5: 
1.8     ! paf         6:        $Id: pa_exception.h,v 1.7 2001/03/11 08:16:32 paf Exp $
1.1       paf         7: */
                      8: 
                      9: #ifndef PA_EXCEPTION_H
                     10: #define PA_EXCEPTION_H
                     11: 
                     12: #include <setjmp.h>
                     13: 
                     14: #include "pa_types.h"
                     15: #include "pa_string.h"
                     16: 
                     17: class Exception {
                     18: public:
                     19: 
1.8     ! paf        20:        Exception() : fhandled(false) {
        !            21:        }
        !            22: 
1.1       paf        23:        // address for long jump to jump to 
1.3       paf        24:        // regretfully public:
                     25:        //   can't make local unless sure of inlining
                     26:        //   for to-die stack frame ruins it all
1.5       paf        27:        mutable jmp_buf mark;
1.1       paf        28: 
1.5       paf        29:        void _throw(
1.1       paf        30:                const String *atype, const String *acode,
                     31:                const String *aproblem_source, 
1.5       paf        32:                const char *comment_fmt, ...) const;
1.1       paf        33: 
1.5       paf        34:        const String *type() const { return ftype; }
                     35:        const String *code() const { return fcode; }
                     36:        const String *problem_source() const { return fproblem_source; }
                     37:        const char *comment() const { return fcomment[0]?fcomment:0; }
1.1       paf        38: 
1.8     ! paf        39:        bool is_handled() { return fhandled; }
        !            40:        void set_handled() { fhandled=true; }
        !            41: 
1.1       paf        42: private:
                     43: 
1.8     ! paf        44:        bool fhandled;
1.5       paf        45:        mutable const String *ftype, *fcode, *fproblem_source;
                     46:        mutable char fcomment[MAX_STRING];
1.1       paf        47: };
                     48: 
1.5       paf        49: //#define EXCEPTION_TRY(e) (setjmp((e).mark)==0)
1.3       paf        50: // usage:
                     51: //   if(EXCEPTION_TRY(e)) { ...; if(?) e.raise(?); ...; } else { catch-code }
1.1       paf        52: 
                     53: #endif

E-mail: