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

1.10      paf         1: /** @file
1.11      paf         2:        Parser: exception decls.
                      3: 
1.45      paf         4:        Copyright (c) 2001-2005 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.47    ! misha      11: static const char * const IDENT_EXCEPTION_H="$Date: 2007/04/23 10:17:36 $";
1.46      misha      12: 
1.47    ! misha      13: const char* const PARSER_RUNTIME = "parser.runtime";
1.1       paf        14: 
1.39      paf        15: // includes
1.14      parser     16: 
1.39      paf        17: #include "pa_memory.h"
                     18: 
                     19: // forwards
                     20: 
                     21: class String;
1.14      parser     22: 
1.22      paf        23: // defines
                     24: 
1.1       paf        25: class Exception {
                     26: public:
                     27: 
1.19      paf        28:        Exception();
1.15      parser     29:        Exception(
1.39      paf        30:                const char* atype,
                     31:                const String* aproblem_source, 
                     32:                const char* comment_fmt, ...);
1.22      paf        33:        Exception(const Exception& src);
1.44      paf        34:        operator bool() { return ftype || fproblem_source || fcomment; }
1.22      paf        35:        Exception& operator =(const Exception& src);
1.1       paf        36: 
1.10      paf        37:        /// extracts exception type
1.39      paf        38:        const char* type(bool can_be_empty=false) const { 
1.35      paf        39:                if(can_be_empty)
                     40:                        return ftype; 
                     41:                else
                     42:                        return ftype?ftype:"<no type>";
                     43:        }
1.10      paf        44:        /// extracts exception problem_source
1.39      paf        45:        const String* problem_source() const;
1.10      paf        46:        /// extracts exception comment
1.39      paf        47:        const char* comment(bool can_be_empty=false) const { 
                     48:                const char* result=fcomment && *fcomment?fcomment:0;
1.35      paf        49:                if(can_be_empty)
                     50:                        return result; 
                     51:                else
                     52:                        return result?result:"<no comment>";
                     53:        }
1.1       paf        54: 
1.40      paf        55: protected:
1.1       paf        56: 
1.39      paf        57:        const char* ftype;
                     58:        const String* fproblem_source;
                     59:        char* fcomment;
1.15      parser     60: 
1.1       paf        61: };
                     62: 
                     63: #endif

E-mail: