Annotation of parser3/src/main/pa_exception.C, revision 1.66
1.13 parser 1: /** @file
2: Parser: exception class.
3:
1.64 moko 4: Copyright (c) 2001-2026 Art. Lebedev Studio (https://www.artlebedev.com)
1.62 moko 5: Authors: Konstantin Morshnev <moko@design.ru>, Alexandr Petrosian <paf@design.ru>
1.41 paf 6: */
1.13 parser 7:
8: #include "pa_common.h"
9: #include "pa_exception.h"
1.44 paf 10: #include "pa_sapi.h"
1.31 paf 11: #include "pa_globals.h"
1.13 parser 12:
1.66 ! moko 13: volatile const char * IDENT_PA_EXCEPTION_C="$Id: pa_exception.C,v 1.65 2026/10/18 21:05:35 moko Exp $" IDENT_PA_EXCEPTION_H;
1.44 paf 14:
15: // methods
16:
17: Exception::Exception(): ftype(0), fproblem_source(0), fcomment(0) {}
1.55 moko 18:
1.44 paf 19: Exception::Exception(const Exception& src):
20: ftype(src.ftype),
1.66 ! moko 21: fproblem_source(pa_gc_reference(src.fproblem_source)),
! 22: fcomment(pa_gc_reference(src.fcomment)) {
1.23 paf 23: }
1.55 moko 24:
1.44 paf 25: Exception& Exception::operator =(const Exception& src) {
26: ftype=src.ftype;
1.66 ! moko 27: fproblem_source=pa_gc_reference(src.fproblem_source);
! 28: fcomment=pa_gc_reference(src.fcomment);
1.44 paf 29: return *this;
30: }
31:
1.55 moko 32: Exception::Exception(const char* atype, const String* aproblem_source, const char* comment_fmt, ...) {
1.30 paf 33: ftype=atype;
1.66 ! moko 34: fproblem_source=aproblem_source ? pa_gc_reference(new String(*aproblem_source)) : 0;
1.27 paf 35:
1.58 moko 36: if(!comment_fmt) {
37: fcomment=0;
38: } else if (!strcmp(comment_fmt, "%s")) { // to avoid MAX_STRING limit
39: va_list args;
40: va_start(args, comment_fmt);
1.61 moko 41: fcomment=va_arg(args, const char *);
1.66 ! moko 42: fcomment=fcomment ? pa_gc_reference(pa_strdup(fcomment)) : 0;
1.58 moko 43: va_end(args);
44: } else {
1.55 moko 45: char comment[MAX_STRING];
1.34 paf 46: va_list args;
47: va_start(args, comment_fmt);
1.66 ! moko 48: fcomment=pa_gc_reference(pa_strdup(comment, pa_vsnprintf(comment, MAX_STRING, comment_fmt, args)));
1.34 paf 49: va_end(args);
1.58 moko 50: }
1.26 paf 51: }
1.44 paf 52:
1.55 moko 53: void Exception::add_comment(const char* acomment) {
1.56 moko 54: if(acomment)
1.66 ! moko 55: fcomment=pa_gc_reference(pa_strcat(fcomment, acomment));
1.55 moko 56: }
57:
58: const String* Exception::problem_source() const {
59: return fproblem_source && !fproblem_source->is_empty() ? fproblem_source : 0;
1.44 paf 60: }
E-mail: