Upstream version 1.3.40
[profile/ivi/swig.git] / Examples / python / exception / example.h
1 /* File : example.h */
2
3 #include <string>
4 #ifndef SWIG
5 struct A {
6 };
7 #endif
8
9 class Exc {
10 public:
11   Exc(int c, const char *m) {
12     code = c;
13     strncpy(msg,m,256);
14   }
15   int code;
16   char msg[256];
17 };
18
19 #if defined(_MSC_VER)
20   #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
21 #endif
22
23 class Test {
24 public:
25   int simple() throw(int) {
26       throw(37);
27       return 1;
28   }
29   int message() throw(const char *) {
30       throw("I died.");
31       return 1;
32   }
33   int hosed() throw(Exc) {
34       throw(Exc(42,"Hosed"));
35       return 1;
36   } 
37   int unknown() throw(A*) {
38       static A a;
39       throw &a;
40       return 1;
41   }
42   int multi(int x) throw(int, const char *, Exc) {
43      if (x == 1) throw(37);
44      if (x == 2) throw("Bleah!");
45      if (x == 3) throw(Exc(42,"No-go-diggy-die"));
46      return 1;
47   }
48 };
49
50 #if defined(_MSC_VER)
51   #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
52 #endif
53