3065 some functions in the tcp module can be static
[unleashed.git] / usr / src / cmd / man / src / util / nsgmls.src / lib / Message.cxx
blob6f3680de7937437fe6894dbbda43648f8b569e3c
1 // Copyright (c) 1994 James Clark
2 // See the file COPYING for copying permission.
3 #pragma ident "%Z%%M% %I% %E% SMI"
5 #ifdef __GNUG__
6 #pragma implementation
7 #endif
9 #include "splib.h"
10 #include "Message.h"
11 #include "MessageArg.h"
13 #ifdef SP_NAMESPACE
14 namespace SP_NAMESPACE {
15 #endif
17 MessageFragment::MessageFragment(unsigned module, unsigned number, const char *
18 #ifndef SP_NO_MESSAGE_TEXT
19 text
20 #endif
22 : module_(module),
23 #ifndef SP_NO_MESSAGE_TEXT
24 text_(text),
25 #endif
26 number_(number)
30 MessageType::MessageType(Severity severity, unsigned module, unsigned number,
31 const char *text, const char *
32 #ifndef SP_NO_MESSAGE_TEXT
33 auxText
34 #endif
37 #ifndef SP_NO_MESSAGE_TEXT
38 auxText_(auxText),
39 #endif
40 MessageFragment(module, number, text)
42 spare_ = severity;
45 MessageType0::MessageType0(Severity severity, unsigned module, unsigned number,
46 const char *text)
47 : MessageType(severity, module, number, text)
51 MessageType1::MessageType1(Severity severity, unsigned module, unsigned number,
52 const char *text)
53 : MessageType(severity, module, number, text)
57 MessageType2::MessageType2(Severity severity, unsigned module, unsigned number,
58 const char *text)
59 : MessageType(severity, module, number, text)
63 MessageType3::MessageType3(Severity severity, unsigned module, unsigned number,
64 const char *text)
65 : MessageType(severity, module, number, text)
69 MessageType4::MessageType4(Severity severity, unsigned module, unsigned number,
70 const char *text)
71 : MessageType(severity, module, number, text)
75 MessageType5::MessageType5(Severity severity, unsigned module, unsigned number,
76 const char *text)
77 : MessageType(severity, module, number, text)
81 MessageType6::MessageType6(Severity severity, unsigned module, unsigned number,
82 const char *text)
83 : MessageType(severity, module, number, text)
87 MessageType0L::MessageType0L(Severity severity, unsigned module, unsigned number,
88 const char *text, const char *auxText)
89 : MessageType(severity, module, number, text, auxText)
93 MessageType1L::MessageType1L(Severity severity, unsigned module, unsigned number,
94 const char *text, const char *auxText)
95 : MessageType(severity, module, number, text, auxText)
99 OpenElementInfo::OpenElementInfo()
100 : included(0), matchIndex(0)
104 Message::Message()
108 Message::Message(int nArgs)
109 : args(nArgs)
113 void Message::swap(Message &to)
115 const MessageType *tem = type;
116 type = to.type;
117 to.type = tem;
118 to.loc.swap(loc);
119 to.auxLoc.swap(auxLoc);
120 args.swap(to.args);
121 openElementInfo.swap(to.openElementInfo);
124 Messenger::Messenger()
125 : haveNextLocation_(0)
129 Messenger::~Messenger()
133 void Messenger::dispatchMessage(Message &msg)
135 const Message &tem = msg;
136 dispatchMessage(tem);
139 void Messenger::message(const MessageType0 &type)
141 Message msg(0);
142 doInitMessage(msg);
143 msg.type = &type;
144 dispatchMessage(msg);
147 void Messenger::message(const MessageType1 &type, const MessageArg &arg0)
149 Message msg(1);
150 doInitMessage(msg);
151 msg.args[0] = arg0.copy();
152 msg.type = &type;
153 dispatchMessage(msg);
156 void Messenger::message(const MessageType2 &type,
157 const MessageArg &arg0,
158 const MessageArg &arg1)
160 Message msg(2);
161 doInitMessage(msg);
162 msg.args[0] = arg0.copy();
163 msg.args[1] = arg1.copy();
164 msg.type = &type;
165 dispatchMessage(msg);
168 void Messenger::message(const MessageType3 &type,
169 const MessageArg &arg0,
170 const MessageArg &arg1,
171 const MessageArg &arg2)
173 Message msg(3);
174 doInitMessage(msg);
175 msg.args[0] = arg0.copy();
176 msg.args[1] = arg1.copy();
177 msg.args[2] = arg2.copy();
178 msg.type = &type;
179 dispatchMessage(msg);
182 void Messenger::message(const MessageType4 &type,
183 const MessageArg &arg0,
184 const MessageArg &arg1,
185 const MessageArg &arg2,
186 const MessageArg &arg3)
188 Message msg(4);
189 doInitMessage(msg);
190 msg.args[0] = arg0.copy();
191 msg.args[1] = arg1.copy();
192 msg.args[2] = arg2.copy();
193 msg.args[3] = arg3.copy();
194 msg.type = &type;
195 dispatchMessage(msg);
198 void Messenger::message(const MessageType5 &type,
199 const MessageArg &arg0,
200 const MessageArg &arg1,
201 const MessageArg &arg2,
202 const MessageArg &arg3,
203 const MessageArg &arg4)
205 Message msg(5);
206 doInitMessage(msg);
207 msg.args[0] = arg0.copy();
208 msg.args[1] = arg1.copy();
209 msg.args[2] = arg2.copy();
210 msg.args[3] = arg3.copy();
211 msg.args[4] = arg4.copy();
212 msg.type = &type;
213 dispatchMessage(msg);
216 void Messenger::message(const MessageType6 &type,
217 const MessageArg &arg0,
218 const MessageArg &arg1,
219 const MessageArg &arg2,
220 const MessageArg &arg3,
221 const MessageArg &arg4,
222 const MessageArg &arg5)
224 Message msg(6);
225 doInitMessage(msg);
226 msg.args[0] = arg0.copy();
227 msg.args[1] = arg1.copy();
228 msg.args[2] = arg2.copy();
229 msg.args[3] = arg3.copy();
230 msg.args[4] = arg4.copy();
231 msg.args[5] = arg5.copy();
232 msg.type = &type;
233 dispatchMessage(msg);
236 void Messenger::message(const MessageType0L &type, const Location &loc)
238 Message msg(0);
239 doInitMessage(msg);
240 msg.type = &type;
241 msg.auxLoc = loc;
242 dispatchMessage(msg);
245 void Messenger::message(const MessageType1L &type, const MessageArg &arg0,
246 const Location &loc)
248 Message msg(1);
249 doInitMessage(msg);
250 msg.args[0] = arg0.copy();
251 msg.type = &type;
252 msg.auxLoc = loc;
253 dispatchMessage(msg);
257 void Messenger::setNextLocation(const Location &loc)
259 haveNextLocation_ = 1;
260 nextLocation_ = loc;
263 void Messenger::initMessage(Message &)
267 void Messenger::doInitMessage(Message &msg)
269 initMessage(msg);
270 if (haveNextLocation_) {
271 msg.loc = nextLocation_;
272 haveNextLocation_ = 0;
276 ForwardingMessenger::ForwardingMessenger(Messenger &to)
277 : to_(&to)
281 void ForwardingMessenger::dispatchMessage(Message &msg)
283 to_->dispatchMessage(msg);
286 void ForwardingMessenger::dispatchMessage(const Message &msg)
288 to_->dispatchMessage(msg);
291 void ForwardingMessenger::initMessage(Message &msg)
293 to_->initMessage(msg);
296 ParentLocationMessenger::ParentLocationMessenger(Messenger &mgr)
297 : ForwardingMessenger(mgr)
301 void ParentLocationMessenger::initMessage(Message &msg)
303 ForwardingMessenger::initMessage(msg);
304 if (!msg.loc.origin().isNull())
305 msg.loc = msg.loc.origin()->parent();
308 NullMessenger::NullMessenger()
312 void NullMessenger::dispatchMessage(const Message &)
316 #ifdef SP_NAMESPACE
318 #endif