1 #ifndef _KVI_KVS_REPORT_H_
2 #define _KVI_KVS_REPORT_H_
3 //=============================================================================
4 //
5 //   File : KviKvsReport.h
6 //   Creation date : Thu 25 Sep 2003 05.12 CEST by Szymon Stefanek
7 //
8 //   This file is part of the KVIrc IRC client distribution
9 //   Copyright (C) 2003-2010 Szymon Stefanek (pragma at kvirc dot net)
10 //
11 //   This program is FREE software. You can redistribute it and/or
12 //   modify it under the terms of the GNU General Public License
13 //   as published by the Free Software Foundation; either version 2
14 //   of the License, or (at your option) any later version.
15 //
16 //   This program is distributed in the HOPE that it will be USEFUL,
17 //   but WITHOUT ANY WARRANTY; without even the implied warranty of
18 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 //   See the GNU General Public License for more details.
20 //
21 //   You should have received a copy of the GNU General Public License
22 //   along with this program. If not, write to the Free Software Foundation,
23 //   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 //
25 //=============================================================================
26 
27 #include "kvi_settings.h"
28 #include "KviQString.h"
29 #include "KviPointerList.h"
30 
31 class KviWindow;
32 
33 class KVIRC_API KviKvsReport
34 {
35 public:
36 	enum Type
37 	{
38 		RunTimeError,
39 		RunTimeWarning,
40 		ParserError,
41 		ParserWarning
42 	};
43 
44 public:
45 	KviKvsReport(Type t, QString szContext, QString szMessage, QString szLocation, KviWindow * pWindow);
46 	~KviKvsReport();
47 
48 protected:
49 	Type m_eType;
50 
51 	// mandatory
52 	QString m_szContext;  // context name (script name, usually)
53 	QString m_szMessage;  // report message, always present
54 	QString m_szLocation; // line and col description (may be some thing like "at end of input")
55 
56 	KviWindow * m_pWindow; // the window that the script was attacched to
57 
58 	// optional
59 	KviPointerList<QString> * m_pCodeListing; // code listing, if present, it is owned
60 	KviPointerList<QString> * m_pCallStack;   // call stack, if present, it is owned
61 public:
type()62 	Type type() const { return m_eType; };
63 
window()64 	KviWindow * window() { return m_pWindow; };
context()65 	const QString & context() { return m_szContext; };
message()66 	const QString & message() { return m_szMessage; };
location()67 	const QString & location() { return m_szLocation; };
codeListing()68 	KviPointerList<QString> * codeListing() { return m_pCodeListing; };
callStack()69 	KviPointerList<QString> * callStack() { return m_pCallStack; };
70 
setContext(const QString & szContext)71 	void setContext(const QString & szContext) { m_szContext = szContext; };
setMessage(const QString & szMessage)72 	void setMessage(const QString & szMessage) { m_szMessage = szMessage; };
setLocation(const QString & szLocation)73 	void setLocation(const QString & szLocation) { m_szLocation = szLocation; };
setCodeListing(KviPointerList<QString> * pListing)74 	void setCodeListing(KviPointerList<QString> * pListing) { m_pCodeListing = pListing; };
setCallStack(KviPointerList<QString> * pStack)75 	void setCallStack(KviPointerList<QString> * pStack) { m_pCallStack = pStack; };
76 
77 	static void findLineAndCol(const QChar * pBegin, const QChar * pPoint, int & iLine, int & iCol);
78 	static void findLineColAndListing(const QChar * pBegin, const QChar * pPoint, int & iLine, int & iCol, KviPointerList<QString> * pListing);
79 
80 	static void report(KviKvsReport * r, KviWindow * pOutput);
81 };
82 
83 #endif //!_KVI_KVS_REPORT_H_
84