File: pa_exception.C

package info (click to toggle)
parser 3.4.5-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 7,552 kB
  • sloc: cpp: 32,375; sh: 11,487; ansic: 10,849; yacc: 1,361; makefile: 248; awk: 5
file content (48 lines) | stat: -rw-r--r-- 1,309 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/** @file
	Parser: exception class.

	Copyright (c) 2001-2017 Art. Lebedev Studio (http://www.artlebedev.com)
	Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
*/

#include "pa_common.h"
#include "pa_exception.h"
#include "pa_sapi.h"
#include "pa_globals.h"

volatile const char * IDENT_PA_EXCEPTION_C="$Id: pa_exception.C,v 1.54 2017/02/07 22:00:43 moko Exp $" IDENT_PA_EXCEPTION_H;

// methods

Exception::Exception(): ftype(0), fproblem_source(0), fcomment(0) {}
Exception::Exception(const Exception& src):
	ftype(src.ftype),
	fproblem_source(src.fproblem_source),
	fcomment(src.fcomment) {
}
Exception& Exception::operator =(const Exception& src) {
	ftype=src.ftype;
	fproblem_source=src.fproblem_source;
	fcomment=src.fcomment;
	return *this;
}

Exception::Exception(const char* atype, 
			const String* aproblem_source, 
			const char* comment_fmt, ...) {
	ftype=atype;
	fproblem_source=aproblem_source ? new String(*aproblem_source) : 0;

	if(comment_fmt) {
		fcomment=new(PointerFreeGC) char[MAX_STRING];
		va_list args;
		va_start(args, comment_fmt);
		vsnprintf((char *)fcomment, MAX_STRING, comment_fmt, args);
		va_end(args);
	} else
		fcomment=0;
}

const String* Exception::problem_source() const { 
	return fproblem_source && !fproblem_source->is_empty()?fproblem_source:0; 
}