Structural deformable models
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  }
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 
47 
48 #endif
#define NULL
Definition: simpletypes.h:9
void setMessage(const char *msg=NULL)
Definition: Errors.h:22
char * message
Definition: Errors.h:43
const char * getMessage() const
Definition: Errors.h:41
IOException(const char *msg=NULL)
Definition: Errors.h:13
~IOException()
Definition: Errors.h:16