KVIrc 5.2.4
Developer APIs
KviKvsScript.h
Go to the documentation of this file.
1#ifndef _KVI_KVS_SCRIPT_H_
2#define _KVI_KVS_SCRIPT_H_
3//=============================================================================
4//
5// File : KviKvsScript.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
33#include "kvi_settings.h"
34#include "KviQString.h"
35#include "KviWindow.h"
36#include "KviPointerList.h"
37#include "KviKvsVariant.h"
38#include "KviKvsVariantList.h"
39#include "KviHeapObject.h"
40
44class KviKvsReport;
46
47// X defines this stuff: ugly :/
48#ifdef Error
49#undef Error
50#endif
51#ifdef Success
52#undef Success
53#endif
54
60{
61 friend class KviKvsObject;
62 friend class KviKvsParser;
64
65public:
71 {
72 Error = 0,
73 Success = 1,
74 HaltEncountered = 2
75 };
76
82 {
85 Parameter
86 };
87
93 {
94 PreserveParams = 1,
95 // FIXME: This should be a global option, eventually
96 AssumeLocals = 2,
97 // FIXME: This should be a global option, eventually
98 Pedantic = 4,
99 Quiet = 8
100 };
101
102public:
111 KviKvsScript(const KviKvsScript & src);
112
120 KviKvsScript(const QString & szName, const QString & szBuffer, ScriptType eType = InstructionList);
121
126
127protected:
136 KviKvsScript(const QString & szName, const QString & szBuffer, KviKvsTreeNodeInstruction * pPreparsedTree, ScriptType eType = InstructionList);
137
138private:
140
141public:
146 const QString & name() const;
147
152 const QString & code() const;
153
160 bool locked() const;
161
167 void setName(const QString & szName);
168
184 int run(KviWindow * pWnd, KviKvsVariantList * pParams = nullptr, KviKvsVariant * pRetVal = nullptr, int iRunFlags = 0, KviKvsExtendedRunTimeData * pExtData = nullptr);
185
202 int run(KviWindow * pWnd, KviKvsVariantList * pParams, QString & szRetVal, int iRunFlags = 0, KviKvsExtendedRunTimeData * pExtData = nullptr);
203
215 int run(KviKvsRunTimeContext * pContext, int iRunFlags = 0);
216
228 static int run(const QString & szCode, KviWindow * pWindow, KviKvsVariantList * pParams = nullptr, KviKvsVariant * pRetVal = nullptr);
229
242 static int evaluate(const QString & szCode, KviWindow * pWindow, KviKvsVariantList * pParams, KviKvsVariant * pRetVal);
243
256 static int evaluateAsString(const QString & szCode, KviWindow * pWindow, KviKvsVariantList * pParams, QString & szRetVal);
257
263 void dump(const char * prefix);
264
265protected:
274 bool parse(KviWindow * pOutput = nullptr, int iRunFlags = 0);
275
288 int execute(KviWindow * pWnd, KviKvsVariantList * pParams = nullptr, KviKvsVariant * pRetVal = nullptr, int iRunFlags = 0, KviKvsExtendedRunTimeData * pExtData = nullptr);
289
298 int executeInternal(KviKvsRunTimeContext * pContext);
299
304 const QChar * buffer() const;
305
310 void detach();
311};
312
318{
319 friend class KviKvsScript;
320
321protected:
322 unsigned int m_uRefs; // Reference count for this structure
323
324 QString m_szName; // script context name
325 QString m_szBuffer; // NEVER TOUCH THIS
326 const QChar * m_pBuffer; // this points to m_szBuffer: use it to extract string data
327
328 KviKvsScript::ScriptType m_eType; // the type of the code in m_szBuffer
329
331 unsigned int m_uLock; // this is increased while the script is being executed
332};
333
334#endif //_KVI_KVS_SCRIPT_H_
Heap Object.
Parser class to handle variant variables lists.
Handling of variant data type in KVS.
C++ Template based double linked pointer list class.
Helper functions for the QString class.
Contains the KviWindow class.
Definition KviHeapObject.h:119
Definition KviKvsRunTimeContext.h:44
Definition KviKvsObject.h:51
Definition KviKvsParser.h:55
Definition KviKvsReport.h:34
Definition KviKvsRunTimeContext.h:104
Holds the data of the script.
Definition KviKvsScript.h:318
unsigned int m_uLock
Definition KviKvsScript.h:331
KviKvsScript::ScriptType m_eType
Definition KviKvsScript.h:328
QString m_szBuffer
Definition KviKvsScript.h:325
QString m_szName
Definition KviKvsScript.h:324
unsigned int m_uRefs
Definition KviKvsScript.h:322
KviKvsTreeNodeInstruction * m_pTree
Definition KviKvsScript.h:330
const QChar * m_pBuffer
Definition KviKvsScript.h:326
The KVIrc Script class.
Definition KviKvsScript.h:60
RunStatus
Holds the run status of the script.
Definition KviKvsScript.h:71
KviKvsScriptData * m_pData
Definition KviKvsScript.h:139
RunFlags
Holds the run flags of the script.
Definition KviKvsScript.h:93
ScriptType
Holds the type of the script.
Definition KviKvsScript.h:82
@ InstructionList
Definition KviKvsScript.h:83
@ Expression
Definition KviKvsScript.h:84
Treenode class to handle instructions.
Definition KviKvsTreeNodeInstruction.h:43
Class to handle variant variables lists.
Definition KviKvsVariantList.h:42
This class defines a new data type which contains variant data.
Definition KviKvsVariant.h:352
Base class for all windows in KVIrc.
Definition KviWindow.h:75
This file contains compile time settings.
#define KVIRC_API
Definition kvi_settings.h:127
char szBuffer[4096]
Definition winamp.cpp:77