0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
** All rights reserved.
|
|
5 |
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
6 |
**
|
|
7 |
** This file is part of the Qt Linguist of the Qt Toolkit.
|
|
8 |
**
|
|
9 |
** $QT_BEGIN_LICENSE:LGPL$
|
|
10 |
** No Commercial Usage
|
|
11 |
** This file contains pre-release code and may not be distributed.
|
|
12 |
** You may use this file in accordance with the terms and conditions
|
|
13 |
** contained in the Technology Preview License Agreement accompanying
|
|
14 |
** this package.
|
|
15 |
**
|
|
16 |
** GNU Lesser General Public License Usage
|
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
18 |
** General Public License version 2.1 as published by the Free Software
|
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
20 |
** packaging of this file. Please review the following information to
|
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
23 |
**
|
|
24 |
** In addition, as a special exception, Nokia gives you certain additional
|
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
27 |
**
|
|
28 |
** If you have questions regarding the use of this file, please contact
|
|
29 |
** Nokia at qt-info@nokia.com.
|
|
30 |
**
|
|
31 |
**
|
|
32 |
**
|
|
33 |
**
|
|
34 |
**
|
|
35 |
**
|
|
36 |
**
|
|
37 |
**
|
|
38 |
** $QT_END_LICENSE$
|
|
39 |
**
|
|
40 |
****************************************************************************/
|
|
41 |
|
|
42 |
#ifndef PROITEMS_H
|
|
43 |
#define PROITEMS_H
|
|
44 |
|
|
45 |
#include <QtCore/QString>
|
|
46 |
#include <QtCore/QList>
|
|
47 |
|
|
48 |
QT_BEGIN_NAMESPACE
|
|
49 |
|
|
50 |
struct AbstractProItemVisitor;
|
|
51 |
|
|
52 |
class ProItem
|
|
53 |
{
|
|
54 |
public:
|
|
55 |
enum ProItemKind {
|
|
56 |
ValueKind,
|
|
57 |
FunctionKind,
|
|
58 |
ConditionKind,
|
|
59 |
OperatorKind,
|
|
60 |
BlockKind
|
|
61 |
};
|
|
62 |
|
|
63 |
enum ProItemReturn {
|
|
64 |
ReturnFalse,
|
|
65 |
ReturnTrue,
|
|
66 |
ReturnBreak,
|
|
67 |
ReturnNext,
|
|
68 |
ReturnLoop,
|
|
69 |
ReturnSkip,
|
|
70 |
ReturnReturn
|
|
71 |
};
|
|
72 |
|
|
73 |
ProItem() : m_lineNumber(0) {}
|
|
74 |
virtual ~ProItem() {}
|
|
75 |
|
|
76 |
virtual ProItemKind kind() const = 0;
|
|
77 |
|
|
78 |
void setComment(const QString &comment);
|
|
79 |
QString comment() const;
|
|
80 |
|
|
81 |
virtual ProItemReturn Accept(AbstractProItemVisitor *visitor) = 0;
|
|
82 |
int lineNumber() const { return m_lineNumber; }
|
|
83 |
void setLineNumber(int lineNumber) { m_lineNumber = lineNumber; }
|
|
84 |
|
|
85 |
private:
|
|
86 |
QString m_comment;
|
|
87 |
int m_lineNumber;
|
|
88 |
};
|
|
89 |
|
|
90 |
class ProBlock : public ProItem
|
|
91 |
{
|
|
92 |
public:
|
|
93 |
enum ProBlockKind {
|
|
94 |
NormalKind = 0x00,
|
|
95 |
ScopeKind = 0x01,
|
|
96 |
ScopeContentsKind = 0x02,
|
|
97 |
VariableKind = 0x04,
|
|
98 |
ProFileKind = 0x08,
|
|
99 |
FunctionBodyKind = 0x10,
|
|
100 |
SingleLine = 0x80
|
|
101 |
};
|
|
102 |
|
|
103 |
ProBlock(ProBlock *parent);
|
|
104 |
~ProBlock();
|
|
105 |
|
|
106 |
void appendItem(ProItem *proitem);
|
|
107 |
void setItems(const QList<ProItem *> &proitems);
|
|
108 |
QList<ProItem *> items() const;
|
|
109 |
|
|
110 |
void setBlockKind(int blockKind);
|
|
111 |
int blockKind() const;
|
|
112 |
|
|
113 |
void setParent(ProBlock *parent);
|
|
114 |
ProBlock *parent() const;
|
|
115 |
|
|
116 |
void ref() { ++m_refCount; }
|
|
117 |
void deref() { if (!--m_refCount) delete this; }
|
|
118 |
|
|
119 |
ProItem::ProItemKind kind() const;
|
|
120 |
|
|
121 |
virtual ProItemReturn Accept(AbstractProItemVisitor *visitor);
|
|
122 |
protected:
|
|
123 |
QList<ProItem *> m_proitems;
|
|
124 |
private:
|
|
125 |
ProBlock *m_parent;
|
|
126 |
int m_blockKind;
|
|
127 |
int m_refCount;
|
|
128 |
};
|
|
129 |
|
|
130 |
class ProVariable : public ProBlock
|
|
131 |
{
|
|
132 |
public:
|
|
133 |
enum VariableOperator {
|
|
134 |
AddOperator = 0,
|
|
135 |
RemoveOperator = 1,
|
|
136 |
ReplaceOperator = 2,
|
|
137 |
SetOperator = 3,
|
|
138 |
UniqueAddOperator = 4
|
|
139 |
};
|
|
140 |
|
|
141 |
ProVariable(const QString &name, ProBlock *parent);
|
|
142 |
|
|
143 |
void setVariableOperator(VariableOperator variableKind);
|
|
144 |
VariableOperator variableOperator() const;
|
|
145 |
|
|
146 |
void setVariable(const QString &name);
|
|
147 |
QString variable() const;
|
|
148 |
|
|
149 |
virtual ProItemReturn Accept(AbstractProItemVisitor *visitor);
|
|
150 |
private:
|
|
151 |
VariableOperator m_variableKind;
|
|
152 |
QString m_variable;
|
|
153 |
};
|
|
154 |
|
|
155 |
class ProValue : public ProItem
|
|
156 |
{
|
|
157 |
public:
|
|
158 |
ProValue(const QString &value, ProVariable *variable);
|
|
159 |
|
|
160 |
void setValue(const QString &value);
|
|
161 |
QString value() const;
|
|
162 |
|
|
163 |
void setVariable(ProVariable *variable);
|
|
164 |
ProVariable *variable() const;
|
|
165 |
|
|
166 |
ProItem::ProItemKind kind() const;
|
|
167 |
|
|
168 |
virtual ProItemReturn Accept(AbstractProItemVisitor *visitor);
|
|
169 |
private:
|
|
170 |
QString m_value;
|
|
171 |
ProVariable *m_variable;
|
|
172 |
};
|
|
173 |
|
|
174 |
class ProFunction : public ProItem
|
|
175 |
{
|
|
176 |
public:
|
|
177 |
explicit ProFunction(const QString &text);
|
|
178 |
|
|
179 |
void setText(const QString &text);
|
|
180 |
QString text() const;
|
|
181 |
|
|
182 |
ProItem::ProItemKind kind() const;
|
|
183 |
|
|
184 |
virtual ProItemReturn Accept(AbstractProItemVisitor *visitor);
|
|
185 |
private:
|
|
186 |
QString m_text;
|
|
187 |
};
|
|
188 |
|
|
189 |
class ProCondition : public ProItem
|
|
190 |
{
|
|
191 |
public:
|
|
192 |
explicit ProCondition(const QString &text);
|
|
193 |
|
|
194 |
void setText(const QString &text);
|
|
195 |
QString text() const;
|
|
196 |
|
|
197 |
ProItem::ProItemKind kind() const;
|
|
198 |
|
|
199 |
virtual ProItemReturn Accept(AbstractProItemVisitor *visitor);
|
|
200 |
private:
|
|
201 |
QString m_text;
|
|
202 |
};
|
|
203 |
|
|
204 |
class ProOperator : public ProItem
|
|
205 |
{
|
|
206 |
public:
|
|
207 |
enum OperatorKind {
|
|
208 |
OrOperator = 1,
|
|
209 |
NotOperator = 2
|
|
210 |
};
|
|
211 |
|
|
212 |
explicit ProOperator(OperatorKind operatorKind);
|
|
213 |
|
|
214 |
void setOperatorKind(OperatorKind operatorKind);
|
|
215 |
OperatorKind operatorKind() const;
|
|
216 |
|
|
217 |
ProItem::ProItemKind kind() const;
|
|
218 |
|
|
219 |
virtual ProItemReturn Accept(AbstractProItemVisitor *visitor);
|
|
220 |
private:
|
|
221 |
OperatorKind m_operatorKind;
|
|
222 |
};
|
|
223 |
|
|
224 |
class ProFile : public ProBlock
|
|
225 |
{
|
|
226 |
public:
|
|
227 |
explicit ProFile(const QString &fileName);
|
|
228 |
~ProFile();
|
|
229 |
|
|
230 |
QString displayFileName() const;
|
|
231 |
QString fileName() const;
|
|
232 |
QString directoryName() const;
|
|
233 |
|
|
234 |
void setModified(bool modified);
|
|
235 |
bool isModified() const;
|
|
236 |
|
|
237 |
virtual ProItemReturn Accept(AbstractProItemVisitor *visitor);
|
|
238 |
|
|
239 |
private:
|
|
240 |
QString m_fileName;
|
|
241 |
QString m_displayFileName;
|
|
242 |
QString m_directoryName;
|
|
243 |
bool m_modified;
|
|
244 |
};
|
|
245 |
|
|
246 |
QT_END_NAMESPACE
|
|
247 |
|
|
248 |
#endif // PROITEMS_H
|