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 librararies 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
52 MessageType::MessageType(Severity severity, unsigned module, unsigned number,
53 const char *text, const char *
54 #ifndef SP_NO_MESSAGE_TEXT
59 #ifndef SP_NO_MESSAGE_TEXT
62 MessageFragment(module, number, text)
67 MessageType0::MessageType0(Severity severity, unsigned module, unsigned number,
69 : MessageType(severity, module, number, text)
73 MessageType1::MessageType1(Severity severity, unsigned module, unsigned number,
75 : MessageType(severity, module, number, text)
79 MessageType2::MessageType2(Severity severity, unsigned module, unsigned number,
81 : MessageType(severity, module, number, text)
85 MessageType3::MessageType3(Severity severity, unsigned module, unsigned number,
87 : MessageType(severity, module, number, text)
91 MessageType4::MessageType4(Severity severity, unsigned module, unsigned number,
93 : MessageType(severity, module, number, text)
97 MessageType5::MessageType5(Severity severity, unsigned module, unsigned number,
99 : MessageType(severity, module, number, text)
103 MessageType6::MessageType6(Severity severity, unsigned module, unsigned number,
105 : MessageType(severity, module, number, text)
109 MessageType0L::MessageType0L(Severity severity, unsigned module, unsigned number,
110 const char *text, const char *auxText)
111 : MessageType(severity, module, number, text, auxText)
115 MessageType1L::MessageType1L(Severity severity, unsigned module, unsigned number,
116 const char *text, const char *auxText)
117 : MessageType(severity, module, number, text, auxText)
121 OpenElementInfo::OpenElementInfo()
122 : included(0), matchIndex(0)
130 Message::Message(int nArgs)
135 void Message::swap(Message &to)
137 const MessageType *tem = type;
141 to.auxLoc.swap(auxLoc);
143 openElementInfo.swap(to.openElementInfo);
146 Messenger::Messenger()
147 : haveNextLocation_(0)
151 Messenger::~Messenger()
155 void Messenger::dispatchMessage(Message &msg)
157 const Message &tem = msg;
158 dispatchMessage(tem);
161 void Messenger::message(const MessageType0 &type)
166 dispatchMessage(msg);
169 void Messenger::message(const MessageType1 &type, const MessageArg &arg0)
173 msg.args[0] = arg0.copy();
175 dispatchMessage(msg);
178 void Messenger::message(const MessageType2 &type,
179 const MessageArg &arg0,
180 const MessageArg &arg1)
184 msg.args[0] = arg0.copy();
185 msg.args[1] = arg1.copy();
187 dispatchMessage(msg);
190 void Messenger::message(const MessageType3 &type,
191 const MessageArg &arg0,
192 const MessageArg &arg1,
193 const MessageArg &arg2)
197 msg.args[0] = arg0.copy();
198 msg.args[1] = arg1.copy();
199 msg.args[2] = arg2.copy();
201 dispatchMessage(msg);
204 void Messenger::message(const MessageType4 &type,
205 const MessageArg &arg0,
206 const MessageArg &arg1,
207 const MessageArg &arg2,
208 const MessageArg &arg3)
212 msg.args[0] = arg0.copy();
213 msg.args[1] = arg1.copy();
214 msg.args[2] = arg2.copy();
215 msg.args[3] = arg3.copy();
217 dispatchMessage(msg);
220 void Messenger::message(const MessageType5 &type,
221 const MessageArg &arg0,
222 const MessageArg &arg1,
223 const MessageArg &arg2,
224 const MessageArg &arg3,
225 const MessageArg &arg4)
229 msg.args[0] = arg0.copy();
230 msg.args[1] = arg1.copy();
231 msg.args[2] = arg2.copy();
232 msg.args[3] = arg3.copy();
233 msg.args[4] = arg4.copy();
235 dispatchMessage(msg);
238 void Messenger::message(const MessageType6 &type,
239 const MessageArg &arg0,
240 const MessageArg &arg1,
241 const MessageArg &arg2,
242 const MessageArg &arg3,
243 const MessageArg &arg4,
244 const MessageArg &arg5)
248 msg.args[0] = arg0.copy();
249 msg.args[1] = arg1.copy();
250 msg.args[2] = arg2.copy();
251 msg.args[3] = arg3.copy();
252 msg.args[4] = arg4.copy();
253 msg.args[5] = arg5.copy();
255 dispatchMessage(msg);
258 void Messenger::message(const MessageType0L &type, const Location &loc)
264 dispatchMessage(msg);
267 void Messenger::message(const MessageType1L &type, const MessageArg &arg0,
272 msg.args[0] = arg0.copy();
275 dispatchMessage(msg);
279 void Messenger::setNextLocation(const Location &loc)
281 haveNextLocation_ = 1;
285 void Messenger::initMessage(Message &)
289 void Messenger::doInitMessage(Message &msg)
292 if (haveNextLocation_) {
293 msg.loc = nextLocation_;
294 haveNextLocation_ = 0;
298 ForwardingMessenger::ForwardingMessenger(Messenger &to)
303 void ForwardingMessenger::dispatchMessage(Message &msg)
305 to_->dispatchMessage(msg);
308 void ForwardingMessenger::dispatchMessage(const Message &msg)
310 to_->dispatchMessage(msg);
313 void ForwardingMessenger::initMessage(Message &msg)
315 to_->initMessage(msg);
318 ParentLocationMessenger::ParentLocationMessenger(Messenger &mgr)
319 : ForwardingMessenger(mgr)
323 void ParentLocationMessenger::initMessage(Message &msg)
325 ForwardingMessenger::initMessage(msg);
326 if (!msg.loc.origin().isNull())
327 msg.loc = msg.loc.origin()->parent();
330 NullMessenger::NullMessenger()
334 void NullMessenger::dispatchMessage(Message &)
338 void NullMessenger::dispatchMessage(const Message &)