Qucs-core
0.0.18
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
qucs-core
src
exceptionstack.cpp
Go to the documentation of this file.
1
/*
2
* exceptionstack.cpp - exception stack class implementation
3
*
4
* Copyright (C) 2004 Stefan Jahn <stefan@lkcc.org>
5
*
6
* This is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2, or (at your option)
9
* any later version.
10
*
11
* This software is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this package; see the file COPYING. If not, write to
18
* the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
19
* Boston, MA 02110-1301, USA.
20
*
21
* $Id$
22
*
23
*/
24
25
#if HAVE_CONFIG_H
26
# include <config.h>
27
#endif
28
29
#include <stdio.h>
30
#include <stdlib.h>
31
#include <string.h>
32
33
#include "
logging.h
"
34
#include "
exception.h
"
35
#include "
exceptionstack.h
"
36
37
using namespace
qucs
;
38
39
// Global exception stack.
40
exceptionstack
qucs::estack
;
41
42
// Constructor creates an instance of the exception stack class.
43
exceptionstack::exceptionstack
() {
44
root = NULL;
45
}
46
47
/* This copy constructor creates a instance of the exception stack
48
class based on the given exception stack. */
49
exceptionstack::exceptionstack
(
const
exceptionstack
& e) {
50
exception
* last, * prev = NULL;
51
for
(
exception
*
next
= e.root;
next
!= NULL;
next
=
next
->getNext ()) {
52
last =
new
exception
(*
next
);
53
if
(prev != NULL)
54
prev->
setNext
(last);
55
else
56
root = last;
57
prev = last;
58
}
59
}
60
61
// Destructor deletes an instance of the exception stack class.
62
exceptionstack::~exceptionstack
() {
63
exception
*
next
;
64
while
(root) {
65
next = root->
getNext
();
66
delete
root;
67
root =
next
;
68
}
69
}
70
71
// The function pushes a new exception onto the exception stack.
72
void
exceptionstack::push
(
exception
* e) {
73
e->
setNext
(root);
74
root = e;
75
}
76
77
/* This function removes the top exception from the exception stack
78
and returns the new top exception. */
79
exception
*
exceptionstack::pop
(
void
) {
80
if
(root != NULL) {
81
exception
*
next
= root->getNext ();
82
delete
root;
83
root =
next
;
84
}
85
return
root;
86
}
87
88
// The function returns the top exception.
89
exception
*
exceptionstack::top
(
void
) {
90
return
root;
91
}
92
93
/* This function prints the complete exception stack and removes each
94
exception from the stack. */
95
void
exceptionstack::print
(
const
char
*
prefix
) {
96
exception
*
next
;
97
if
(root)
98
logprint
(
LOG_ERROR
,
"%s%sexception stack\n"
,
99
prefix ? prefix :
""
, prefix ?
" "
:
""
);
100
while
((next =
top
()) != NULL) {
101
logprint
(
LOG_ERROR
,
" %03d: %s\n"
, next->
getCode
(), next->
getText
());
102
pop
();
103
}
104
}
qucs::exceptionstack::top
exception top(void)
Definition:
exceptionstack.cpp:89
qucs::exceptionstack::exceptionstack
exceptionstack()
Definition:
exceptionstack.cpp:43
qucs::estack
exceptionstack estack
Definition:
exceptionstack.h:48
qucs::exceptionstack
Definition:
exceptionstack.h:32
logging.h
exception.h
qucs::exception::getNext
exception getNext(void)
Definition:
exception.h:54
next
next
Definition:
parse_spice.y:859
qucs::exception::getText
char * getText(void)
Definition:
exception.h:52
qucs::exception
Definition:
exception.h:43
qucs
Definition:
applications.h:30
exceptionstack.h
qucs::exceptionstack::print
void print(const char *prefix=NULL)
Definition:
exceptionstack.cpp:95
qucs::exception::setNext
void setNext(exception *e)
Definition:
exception.h:55
prefix
name prefix
Definition:
parse_spice.y:131
LOG_ERROR
#define LOG_ERROR
Definition:
logging.h:28
qucs::exceptionstack::~exceptionstack
~exceptionstack()
Definition:
exceptionstack.cpp:62
logprint
void logprint(int level, const char *format,...)
Definition:
logging.c:37
qucs::exceptionstack::pop
exception pop(void)
Definition:
exceptionstack.cpp:79
qucs::exceptionstack::push
void push(exception *)
Definition:
exceptionstack.cpp:72
qucs::exception::getCode
int getCode(void)
Definition:
exception.h:50
Generated on Mon Sep 1 2014 20:08:26 for Qucs-core by
1.8.6