2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2010-03-05 11:25:49 +01:00
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-06-17 00:01:27 +10:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Commercial Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** If you are unsure which license is appropriate for your use, please
|
2009-08-14 09:30:56 +02:00
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 12:57:59 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#ifndef PROITEMS_H
|
|
|
|
|
#define PROITEMS_H
|
|
|
|
|
|
|
|
|
|
#include <QtCore/QString>
|
|
|
|
|
#include <QtCore/QList>
|
|
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
|
2010-02-26 12:53:30 +01:00
|
|
|
#ifdef PROPARSER_THREAD_SAFE
|
|
|
|
|
typedef QAtomicInt ProItemRefCount;
|
|
|
|
|
#else
|
|
|
|
|
class ProItemRefCount {
|
|
|
|
|
public:
|
|
|
|
|
ProItemRefCount() : m_cnt(0) {}
|
|
|
|
|
bool ref() { return ++m_cnt != 0; }
|
|
|
|
|
bool deref() { return --m_cnt != 0; }
|
|
|
|
|
ProItemRefCount &operator=(int value) { m_cnt = value; return *this; }
|
|
|
|
|
private:
|
|
|
|
|
int m_cnt;
|
|
|
|
|
};
|
|
|
|
|
#endif
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
class ProItem
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
enum ProItemKind {
|
|
|
|
|
ConditionKind,
|
|
|
|
|
OperatorKind,
|
2010-01-14 12:34:46 +01:00
|
|
|
VariableKind,
|
2008-12-02 12:01:29 +01:00
|
|
|
BlockKind
|
|
|
|
|
};
|
2008-12-04 20:51:30 +01:00
|
|
|
|
2009-05-18 17:46:30 +02:00
|
|
|
enum ProItemReturn {
|
|
|
|
|
ReturnFalse,
|
|
|
|
|
ReturnTrue,
|
2009-05-19 19:00:06 +02:00
|
|
|
ReturnBreak,
|
|
|
|
|
ReturnNext,
|
|
|
|
|
ReturnLoop,
|
2009-05-18 17:46:30 +02:00
|
|
|
ReturnSkip,
|
|
|
|
|
ReturnReturn
|
|
|
|
|
};
|
|
|
|
|
|
2010-02-03 10:23:23 +01:00
|
|
|
ProItem(ProItemKind kind) : m_kind(kind), m_lineNumber(0) {}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-02-03 10:23:23 +01:00
|
|
|
ProItemKind kind() const { return m_kind; }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
int lineNumber() const { return m_lineNumber; }
|
|
|
|
|
void setLineNumber(int lineNumber) { m_lineNumber = lineNumber; }
|
|
|
|
|
|
2010-02-03 16:50:11 +01:00
|
|
|
ProItem *next() const { return m_next; }
|
|
|
|
|
ProItem **nextRef() { return &m_next; }
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
private:
|
2010-02-03 16:50:11 +01:00
|
|
|
ProItem *m_next;
|
2010-02-03 10:23:23 +01:00
|
|
|
ProItemKind m_kind;
|
2008-12-02 12:01:29 +01:00
|
|
|
int m_lineNumber;
|
2010-02-03 16:50:11 +01:00
|
|
|
|
|
|
|
|
friend class ProBlock; // C++ is braindead ...
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ProBlock : public ProItem
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
enum ProBlockKind {
|
|
|
|
|
NormalKind = 0x00,
|
|
|
|
|
ScopeKind = 0x01,
|
|
|
|
|
ScopeContentsKind = 0x02,
|
|
|
|
|
ProFileKind = 0x08,
|
2009-05-18 17:46:30 +02:00
|
|
|
FunctionBodyKind = 0x10,
|
|
|
|
|
SingleLine = 0x80
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
2010-02-03 10:08:45 +01:00
|
|
|
ProBlock();
|
2008-12-02 12:01:29 +01:00
|
|
|
~ProBlock();
|
|
|
|
|
|
2010-02-03 10:09:15 +01:00
|
|
|
void setBlockKind(int blockKind) { m_blockKind = blockKind; }
|
|
|
|
|
int blockKind() const { return m_blockKind; }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-02-03 16:50:11 +01:00
|
|
|
ProItem *items() const { return m_proitems; }
|
|
|
|
|
ProItem **itemsRef() { return &m_proitems; }
|
|
|
|
|
|
2010-02-26 12:53:30 +01:00
|
|
|
void ref() { m_refCount.ref(); }
|
|
|
|
|
void deref() { if (!m_refCount.deref()) delete this; }
|
2009-05-18 17:46:30 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
private:
|
2010-02-03 16:50:11 +01:00
|
|
|
ProItem *m_proitems;
|
2008-12-02 12:01:29 +01:00
|
|
|
int m_blockKind;
|
2010-04-01 15:58:00 +02:00
|
|
|
friend class ProFile; // for the pseudo-virtual d'tor
|
2010-02-26 12:53:30 +01:00
|
|
|
ProItemRefCount m_refCount;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
2010-01-14 12:34:46 +01:00
|
|
|
class ProVariable : public ProItem
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
enum VariableOperator {
|
|
|
|
|
AddOperator = 0,
|
|
|
|
|
RemoveOperator = 1,
|
|
|
|
|
ReplaceOperator = 2,
|
|
|
|
|
SetOperator = 3,
|
|
|
|
|
UniqueAddOperator = 4
|
|
|
|
|
};
|
|
|
|
|
|
2010-02-03 10:23:23 +01:00
|
|
|
ProVariable(const QString &name) : ProItem(VariableKind), m_variableKind(SetOperator), m_variable(name) {}
|
2010-02-03 10:09:15 +01:00
|
|
|
void setVariableOperator(VariableOperator variableKind) { m_variableKind = variableKind; }
|
|
|
|
|
VariableOperator variableOperator() const { return m_variableKind; }
|
|
|
|
|
void setVariable(const QString &name) { m_variable = name; }
|
|
|
|
|
QString variable() const { return m_variable; }
|
|
|
|
|
void setValue(const QString &value) { m_value = value; }
|
|
|
|
|
QString value() const { return m_value; }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
private:
|
2010-01-14 12:34:46 +01:00
|
|
|
VariableOperator m_variableKind;
|
|
|
|
|
QString m_variable;
|
2008-12-02 12:01:29 +01:00
|
|
|
QString m_value;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ProCondition : public ProItem
|
|
|
|
|
{
|
|
|
|
|
public:
|
2010-02-03 10:23:23 +01:00
|
|
|
explicit ProCondition(const QString &text) : ProItem(ConditionKind), m_text(text) {}
|
2010-02-03 10:09:15 +01:00
|
|
|
void setText(const QString &text) { m_text = text; }
|
|
|
|
|
QString text() const { return m_text; }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QString m_text;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ProOperator : public ProItem
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
enum OperatorKind {
|
|
|
|
|
OrOperator = 1,
|
|
|
|
|
NotOperator = 2
|
|
|
|
|
};
|
|
|
|
|
|
2010-02-03 10:23:23 +01:00
|
|
|
explicit ProOperator(OperatorKind operatorKind) : ProItem(ProItem::OperatorKind), m_operatorKind(operatorKind) {}
|
2010-02-03 10:09:15 +01:00
|
|
|
void setOperatorKind(OperatorKind operatorKind) { m_operatorKind = operatorKind; }
|
|
|
|
|
OperatorKind operatorKind() const { return m_operatorKind; }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
OperatorKind m_operatorKind;
|
|
|
|
|
};
|
|
|
|
|
|
2009-06-15 13:55:25 +02:00
|
|
|
class ProFile : public ProBlock
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
explicit ProFile(const QString &fileName);
|
|
|
|
|
|
2010-02-03 10:09:15 +01:00
|
|
|
QString displayFileName() const { return m_displayFileName; }
|
|
|
|
|
QString fileName() const { return m_fileName; }
|
|
|
|
|
QString directoryName() const { return m_directoryName; }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-04-01 15:58:00 +02:00
|
|
|
// d'tor is not virtual
|
|
|
|
|
void deref() { if (!m_refCount.deref()) delete this; }
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
private:
|
|
|
|
|
QString m_fileName;
|
|
|
|
|
QString m_displayFileName;
|
2008-12-19 21:35:10 +01:00
|
|
|
QString m_directoryName;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
|
|
#endif // PROITEMS_H
|