1 /*
2 	Actiona
3 	Copyright (C) 2005 Jonathan Mercier-Ganady
4 
5 	Actiona is free software: you can redistribute it and/or modify
6 	it under the terms of the GNU General Public License as published by
7 	the Free Software Foundation, either version 3 of the License, or
8 	(at your option) any later version.
9 
10 	Actiona is distributed in the hope that it will be useful,
11 	but WITHOUT ANY WARRANTY; without even the implied warranty of
12 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 	GNU General Public License for more details.
14 
15 	You should have received a copy of the GNU General Public License
16 	along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18 	Contact : jmgr@jmgr.info
19 */
20 
21 #include "actionexception.h"
22 
23 #include <QDebug>
24 #include <QDataStream>
25 
26 namespace ActionTools
27 {
28 	QString ActionException::ExceptionName[ExceptionCount] =
29 	{
30 		QStringLiteral(QT_TRANSLATE_NOOP("ActionException::ExceptionName", "Invalid parameter")),
31 		QStringLiteral(QT_TRANSLATE_NOOP("ActionException::ExceptionName", "Code error")),
32 		QStringLiteral(QT_TRANSLATE_NOOP("ActionException::ExceptionName", "Timeout"))
33 	};
34 
35 	ActionException::ExceptionAction ActionException::ExceptionDefaultAction[ExceptionCount] =
36 	{
37 		StopExecutionExceptionAction,
38 		StopExecutionExceptionAction,
39 		SkipExceptionAction
40 	};
41 
42 	QString ActionException::ExceptionActionName[ExceptionActionCount] =
43 	{
44 		QStringLiteral(QT_TRANSLATE_NOOP("ActionException::ExceptionActionName", "Stop execution")),
45 		QStringLiteral(QT_TRANSLATE_NOOP("ActionException::ExceptionActionName", "Skip current action")),
46 		QStringLiteral(QT_TRANSLATE_NOOP("ActionException::ExceptionActionName", "Goto a line"))
47 	};
48 
operator >>(QDataStream & s,ActionException::Exception & exception)49 	QDataStream &operator >> (QDataStream &s, ActionException::Exception &exception)
50 	{
51 		int newException;
52 
53 		s >> newException;
54 
55 		exception = static_cast<ActionException::Exception>(newException);
56 
57 		return s;
58 	}
59 
operator >>(QDataStream & s,ActionException::ExceptionAction & exceptionAction)60 	QDataStream &operator >> (QDataStream &s, ActionException::ExceptionAction &exceptionAction)
61 	{
62 		int newExceptionAction;
63 
64 		s >> newExceptionAction;
65 
66 		exceptionAction = static_cast<ActionException::ExceptionAction>(newExceptionAction);
67 
68 		return s;
69 	}
70 
operator >>(QDataStream & s,ActionException::ExceptionActionInstance & exceptionActionInstance)71 	QDataStream &operator >> (QDataStream &s, ActionException::ExceptionActionInstance &exceptionActionInstance)
72 	{
73 		ActionException::ExceptionAction action;
74 		QString line;
75 
76 		s >> action;
77 		s >> line;
78 
79 		exceptionActionInstance.setAction(action);
80 		exceptionActionInstance.setLine(line);
81 
82 		return s;
83 	}
84 
operator <<(QDataStream & s,const ActionException::ExceptionActionInstance & exceptionActionInstance)85 	QDataStream &operator << (QDataStream &s, const ActionException::ExceptionActionInstance &exceptionActionInstance)
86 	{
87 		s << exceptionActionInstance.action();
88 		s << exceptionActionInstance.line();
89 
90 		return s;
91 	}
92 
operator <<(QDebug & dbg,const ActionException::ExceptionActionInstance & exceptionActionInstance)93 	QDebug &operator << (QDebug &dbg, const ActionException::ExceptionActionInstance &exceptionActionInstance)
94 	{
95 		dbg.space() << exceptionActionInstance.action();
96 		dbg.space() << exceptionActionInstance.line();
97 
98 		return dbg.maybeSpace();
99 	}
100 }
101