2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: Message.C /main/1 1996/07/29 16:56:53 cde-hp $ */
24 // Copyright (c) 1994 James Clark
25 // See the file COPYING for copying permission.
28 #pragma implementation
33 #include "MessageArg.h"
36 namespace SP_NAMESPACE {
39 MessageFragment::MessageFragment(unsigned module, unsigned number, const char *
40 #ifndef SP_NO_MESSAGE_TEXT
45 #ifndef SP_NO_MESSAGE_TEXT
53 MessageType::MessageType(Severity severity, unsigned module, unsigned number,
54 const char *text, const char *
55 #ifndef SP_NO_MESSAGE_TEXT
60 #ifndef SP_NO_MESSAGE_TEXT
63 MessageFragment(module, number, text)
68 MessageType0::MessageType0(Severity severity, unsigned module, unsigned number,
70 : MessageType(severity, module, number, text)
74 MessageType1::MessageType1(Severity severity, unsigned module, unsigned number,
76 : MessageType(severity, module, number, text)
80 MessageType2::MessageType2(Severity severity, unsigned module, unsigned number,
82 : MessageType(severity, module, number, text)
86 MessageType3::MessageType3(Severity severity, unsigned module, unsigned number,
88 : MessageType(severity, module, number, text)
92 MessageType4::MessageType4(Severity severity, unsigned module, unsigned number,
94 : MessageType(severity, module, number, text)
98 MessageType5::MessageType5(Severity severity, unsigned module, unsigned number,
100 : MessageType(severity, module, number, text)
104 MessageType6::MessageType6(Severity severity, unsigned module, unsigned number,
106 : MessageType(severity, module, number, text)
110 MessageType0L::MessageType0L(Severity severity, unsigned module, unsigned number,
111 const char *text, const char *auxText)
112 : MessageType(severity, module, number, text, auxText)
116 MessageType1L::MessageType1L(Severity severity, unsigned module, unsigned number,
117 const char *text, const char *auxText)
118 : MessageType(severity, module, number, text, auxText)
122 OpenElementInfo::OpenElementInfo()
123 : included(0), matchIndex(0)
132 Message::Message(int nArgs)
133 : args(nArgs), type(NULL)
137 void Message::swap(Message &to)
139 const MessageType *tem = type;
143 to.auxLoc.swap(auxLoc);
145 openElementInfo.swap(to.openElementInfo);
148 Messenger::Messenger()
149 : haveNextLocation_(0)
153 Messenger::~Messenger()
157 void Messenger::dispatchMessage(Message &msg)
159 const Message &tem = msg;
160 dispatchMessage(tem);
163 void Messenger::message(const MessageType0 &type)
168 dispatchMessage(msg);
171 void Messenger::message(const MessageType1 &type, const MessageArg &arg0)
175 msg.args[0] = arg0.copy();
177 dispatchMessage(msg);
180 void Messenger::message(const MessageType2 &type,
181 const MessageArg &arg0,
182 const MessageArg &arg1)
186 msg.args[0] = arg0.copy();
187 msg.args[1] = arg1.copy();
189 dispatchMessage(msg);
192 void Messenger::message(const MessageType3 &type,
193 const MessageArg &arg0,
194 const MessageArg &arg1,
195 const MessageArg &arg2)
199 msg.args[0] = arg0.copy();
200 msg.args[1] = arg1.copy();
201 msg.args[2] = arg2.copy();
203 dispatchMessage(msg);
206 void Messenger::message(const MessageType4 &type,
207 const MessageArg &arg0,
208 const MessageArg &arg1,
209 const MessageArg &arg2,
210 const MessageArg &arg3)
214 msg.args[0] = arg0.copy();
215 msg.args[1] = arg1.copy();
216 msg.args[2] = arg2.copy();
217 msg.args[3] = arg3.copy();
219 dispatchMessage(msg);
222 void Messenger::message(const MessageType5 &type,
223 const MessageArg &arg0,
224 const MessageArg &arg1,
225 const MessageArg &arg2,
226 const MessageArg &arg3,
227 const MessageArg &arg4)
231 msg.args[0] = arg0.copy();
232 msg.args[1] = arg1.copy();
233 msg.args[2] = arg2.copy();
234 msg.args[3] = arg3.copy();
235 msg.args[4] = arg4.copy();
237 dispatchMessage(msg);
240 void Messenger::message(const MessageType6 &type,
241 const MessageArg &arg0,
242 const MessageArg &arg1,
243 const MessageArg &arg2,
244 const MessageArg &arg3,
245 const MessageArg &arg4,
246 const MessageArg &arg5)
250 msg.args[0] = arg0.copy();
251 msg.args[1] = arg1.copy();
252 msg.args[2] = arg2.copy();
253 msg.args[3] = arg3.copy();
254 msg.args[4] = arg4.copy();
255 msg.args[5] = arg5.copy();
257 dispatchMessage(msg);
260 void Messenger::message(const MessageType0L &type, const Location &loc)
266 dispatchMessage(msg);
269 void Messenger::message(const MessageType1L &type, const MessageArg &arg0,
274 msg.args[0] = arg0.copy();
277 dispatchMessage(msg);
281 void Messenger::setNextLocation(const Location &loc)
283 haveNextLocation_ = 1;
287 void Messenger::initMessage(Message &)
291 void Messenger::doInitMessage(Message &msg)
294 if (haveNextLocation_) {
295 msg.loc = nextLocation_;
296 haveNextLocation_ = 0;
300 ForwardingMessenger::ForwardingMessenger(Messenger &to)
305 void ForwardingMessenger::dispatchMessage(Message &msg)
307 to_->dispatchMessage(msg);
310 void ForwardingMessenger::dispatchMessage(const Message &msg)
312 to_->dispatchMessage(msg);
315 void ForwardingMessenger::initMessage(Message &msg)
317 to_->initMessage(msg);
320 ParentLocationMessenger::ParentLocationMessenger(Messenger &mgr)
321 : ForwardingMessenger(mgr)
325 void ParentLocationMessenger::initMessage(Message &msg)
327 ForwardingMessenger::initMessage(msg);
328 if (!msg.loc.origin().isNull())
329 msg.loc = msg.loc.origin()->parent();
332 NullMessenger::NullMessenger()
336 void NullMessenger::dispatchMessage(Message &)
340 void NullMessenger::dispatchMessage(const Message &)