]> ncurses.scripts.mit.edu Git - ncurses.git/blob - c++/etip.h
ncurses 4.1
[ncurses.git] / c++ / etip.h
1 #ifndef _ETIP_H
2 #define _ETIP_H
3
4 #ifdef __GNUG__
5 #if HAVE_TYPEINFO
6 #  include <typeinfo>
7 #endif
8 #endif
9
10 #include <eti.h>
11
12 // Forward Declarations
13 class NCursesPanel;
14 class NCursesMenu;
15 class NCursesForm;
16
17 class NCursesException
18 {
19 public:
20   int errorno;
21   const char *message;
22
23   NCursesException (const char* msg, int err)
24     : message(msg), errorno (err)
25     {};
26
27   NCursesException (const char* msg)
28     : message(msg), errorno (E_SYSTEM_ERROR)
29     {};
30
31   virtual const char *classname() const {
32     return "NCursesWindow";
33   }
34 };
35
36 class NCursesPanelException : public NCursesException
37 {
38 public:
39   const NCursesPanel* p;
40
41   NCursesPanelException (const char *msg, int err) : 
42     NCursesException (msg, err),
43     p ((NCursesPanel*)0)
44     {};
45
46   NCursesPanelException (const NCursesPanel* panel,
47                          const char *msg,
48                          int err) : 
49     NCursesException (msg, err),
50     p (panel)
51     {};
52
53   NCursesPanelException (int err) : 
54     NCursesException ("panel library error", err),
55     p ((NCursesPanel*)0)
56     {};
57
58   NCursesPanelException (const NCursesPanel* panel,
59                          int err) : 
60     NCursesException ("panel library error", err),
61     p (panel)
62     {};
63
64   virtual const char *classname() const {
65     return "NCursesPanel";
66   }
67
68 };
69
70 class NCursesMenuException : public NCursesException
71 {
72 public:
73   const NCursesMenu* m;
74
75   NCursesMenuException (const char *msg, int err) : 
76     NCursesException (msg, err),
77     m ((NCursesMenu *)0)
78     {};
79
80   NCursesMenuException (const NCursesMenu* menu,
81                         const char *msg,
82                         int err) : 
83     NCursesException (msg, err),
84     m (menu)
85     {};
86
87   NCursesMenuException (int err) : 
88     NCursesException ("menu library error", err),
89     m ((NCursesMenu *)0)
90     {};
91
92   NCursesMenuException (const NCursesMenu* menu,
93                         int err) : 
94     NCursesException ("menu library error", err),
95     m (menu)
96     {};
97
98   virtual const char *classname() const {
99     return "NCursesMenu";
100   }
101
102 };
103
104 class NCursesFormException : public NCursesException
105 {
106 public:
107   const NCursesForm* f;
108
109   NCursesFormException (const char *msg, int err) : 
110     NCursesException (msg, err),
111     f ((NCursesForm*)0)
112     {};
113
114   NCursesFormException (const NCursesForm* form,
115                         const char *msg,
116                         int err) : 
117     NCursesException (msg, err),
118     f (form)
119     {};
120
121   NCursesFormException (int err) : 
122     NCursesException ("form library error", err),
123     f ((NCursesForm*)0)
124     {};
125
126   NCursesFormException (const NCursesForm* form,
127                         int err) : 
128     NCursesException ("form library error", err),
129     f (form)
130     {};
131
132   virtual const char *classname() const {
133     return "NCursesForm";
134   }
135
136 };
137
138 inline void THROW(const NCursesException *e) {
139 #if defined(__GNUG__)
140   (*lib_error_handler)(e?e->classname():"",e?e->message:"");
141 #else  // #elif defined(__SUNPRO_CC)
142   genericerror(1, ((e != 0) ? (char *)(e->message) : ""));
143 #endif     
144 }
145
146 #define THROWS(s)
147  
148 #endif