--- parser3/src/main/pa_exception.C 2001/08/27 13:40:41 1.13 +++ parser3/src/main/pa_exception.C 2001/11/15 20:26:34 1.26 @@ -2,36 +2,144 @@ Parser: exception class. Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) + Author: Alexander Petrosyan (http://paf.design.ru) - Author: Alexander Petrosyan (http://design.ru/paf) + $Id: pa_exception.C,v 1.26 2001/11/15 20:26:34 paf Exp $ */ -static const char *RCSId="$Id: pa_exception.C,v 1.13 2001/08/27 13:40:41 parser Exp $"; - -#include -#include #include "pa_common.h" #include "pa_exception.h" -void Exception::_throw(const String *atype, const String *acode, +Exception::Exception() { + ftype=fcode=fproblem_source=0; + owns_comment=false; fcomment=0; +} +Exception::Exception(const String *atype, const String *acode, const String *aproblem_source, - const char *comment_fmt, ...) const { + const char *comment_fmt, ...) { + //_asm int 3; ftype=atype; fcode=acode; fproblem_source=aproblem_source; + owns_comment=true; if(comment_fmt) { va_list args; va_start(args, comment_fmt); + fcomment=(char *)malloc(MAX_STRING); vsnprintf(fcomment, MAX_STRING, comment_fmt, args); va_end(args); - } else - fcomment[0]=0; + } else + fcomment=0; +} +Exception::Exception(const Exception& src) : + ftype(src.ftype), + fcode(src.fcode), + fproblem_source(src.fproblem_source), + fcomment(src.fcomment), + owns_comment(src.owns_comment) { + // that ugly string got from STL, along with principal ideal + const_cast(&src)->owns_comment=false; +} +Exception& Exception::operator =(const Exception& src) { + ftype=src.ftype; + fcode=src.fcode; + fproblem_source=src.fproblem_source; + + if(owns_comment) + free(fcomment); + fcomment=src.fcomment; + // that ugly string got from STL, along with principal ideal + owns_comment=src.owns_comment; ((Exception*)&src)->owns_comment=false; + + return *this; +} +Exception::~Exception() { + if(owns_comment) + free(fcomment); +} - int *p=(int *)(void *)&mark; - for(int i=0; i