Structural deformable models
Main Page
Namespaces
Classes
Files
File List
File Members
src
Errors.h
Go to the documentation of this file.
1
/* -*- C++ -*- */
2
#ifndef _ERRORS_H_
3
#define _ERRORS_H_
4
5
#include <string.h>
6
7
// a collection of exceptions that can be thrown
8
9
class
Exception
{};
10
11
class
IOException
:
public
Exception
{
12
public
:
13
IOException
(
const
char
* msg =
NULL
) : message(
NULL
) {
14
setMessage(msg);
15
}
16
~IOException
() {
17
if
(message) {
18
delete
message;
19
message =
NULL
;
20
}
21
}
22
void
setMessage
(
const
char
* msg=
NULL
) {
23
if
(!msg) {
24
if
(message) {
25
if
(message[0] != 0) {
26
delete
message;
27
message =
new
char
[1];
28
message[0] = 0;
29
}
30
}
else
{
31
message =
new
char
[1];
32
message[0] = 0;
33
}
34
return
;
35
}
36
int
len = strlen(msg);
37
if
(!len) setMessage(
NULL
);
38
message =
new
char
[len+1];
39
strcpy(message, msg);
40
}
41
const
char
*
getMessage
()
const
{
return
message; }
42
protected
:
43
char
*
message
;
44
};
45
46
class
SyntaxErrorException
:
public
IOException
{};
47
48
#endif
NULL
#define NULL
Definition:
simpletypes.h:9
IOException::setMessage
void setMessage(const char *msg=NULL)
Definition:
Errors.h:22
IOException::message
char * message
Definition:
Errors.h:43
IOException
Definition:
Errors.h:11
IOException::getMessage
const char * getMessage() const
Definition:
Errors.h:41
SyntaxErrorException
Definition:
Errors.h:46
IOException::IOException
IOException(const char *msg=NULL)
Definition:
Errors.h:13
IOException::~IOException
~IOException()
Definition:
Errors.h:16
Exception
Definition:
Errors.h:9
Generated by
1.8.11