| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** Contact: Qt Software Information (qt-info@nokia.com)
|
|---|
| 5 | **
|
|---|
| 6 | ** This file is part of the tools applications of the Qt Toolkit.
|
|---|
| 7 | **
|
|---|
| 8 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 9 | ** Commercial Usage
|
|---|
| 10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 11 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 12 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 13 | ** a written agreement between you and Nokia.
|
|---|
| 14 | **
|
|---|
| 15 | ** GNU Lesser General Public License Usage
|
|---|
| 16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 17 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 19 | ** packaging of this file. Please review the following information to
|
|---|
| 20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 22 | **
|
|---|
| 23 | ** In addition, as a special exception, Nokia gives you certain
|
|---|
| 24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
|---|
| 25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
|---|
| 26 | ** package.
|
|---|
| 27 | **
|
|---|
| 28 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you are unsure which license is appropriate for your use, please
|
|---|
| 37 | ** contact the sales department at qt-sales@nokia.com.
|
|---|
| 38 | ** $QT_END_LICENSE$
|
|---|
| 39 | **
|
|---|
| 40 | ****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | /*
|
|---|
| 43 | location.h
|
|---|
| 44 | */
|
|---|
| 45 |
|
|---|
| 46 | #ifndef LOCATION_H
|
|---|
| 47 | #define LOCATION_H
|
|---|
| 48 |
|
|---|
| 49 | #include <qstack.h>
|
|---|
| 50 |
|
|---|
| 51 | #include "tr.h"
|
|---|
| 52 |
|
|---|
| 53 | #define QDOC_QML
|
|---|
| 54 |
|
|---|
| 55 | QT_BEGIN_NAMESPACE
|
|---|
| 56 |
|
|---|
| 57 | class Config;
|
|---|
| 58 | class QRegExp;
|
|---|
| 59 |
|
|---|
| 60 | class Location
|
|---|
| 61 | {
|
|---|
| 62 | public:
|
|---|
| 63 | Location();
|
|---|
| 64 | Location(const QString& filePath);
|
|---|
| 65 | Location(const Location& other);
|
|---|
| 66 | ~Location() { delete stk; }
|
|---|
| 67 |
|
|---|
| 68 | Location& operator=(const Location& other);
|
|---|
| 69 |
|
|---|
| 70 | void start();
|
|---|
| 71 | void advance(QChar ch);
|
|---|
| 72 | void advanceLines(int n) { stkTop->lineNo += n; stkTop->columnNo = 1; }
|
|---|
| 73 |
|
|---|
| 74 | void push(const QString& filePath);
|
|---|
| 75 | void pop();
|
|---|
| 76 | void setEtc(bool etc) { etcetera = etc; }
|
|---|
| 77 | void setLineNo(int no) { stkTop->lineNo = no; }
|
|---|
| 78 | void setColumnNo(int no) { stkTop->columnNo = no; }
|
|---|
| 79 |
|
|---|
| 80 | bool isEmpty() const { return stkDepth == 0; }
|
|---|
| 81 | int depth() const { return stkDepth; }
|
|---|
| 82 | const QString& filePath() const { return stkTop->filePath; }
|
|---|
| 83 | QString fileName() const;
|
|---|
| 84 | int lineNo() const { return stkTop->lineNo; }
|
|---|
| 85 | int columnNo() const { return stkTop->columnNo; }
|
|---|
| 86 | bool etc() const { return etcetera; }
|
|---|
| 87 | void warning(const QString& message,
|
|---|
| 88 | const QString& details = QString()) const;
|
|---|
| 89 | void error(const QString& message,
|
|---|
| 90 | const QString& details = QString()) const;
|
|---|
| 91 | void fatal(const QString& message,
|
|---|
| 92 | const QString& details = QString()) const;
|
|---|
| 93 |
|
|---|
| 94 | QT_STATIC_CONST Location null;
|
|---|
| 95 |
|
|---|
| 96 | static void initialize(const Config& config);
|
|---|
| 97 | static void terminate();
|
|---|
| 98 | static void information(const QString& message);
|
|---|
| 99 | static void internalError(const QString& hint);
|
|---|
| 100 |
|
|---|
| 101 | private:
|
|---|
| 102 | enum MessageType { Warning, Error };
|
|---|
| 103 |
|
|---|
| 104 | struct StackEntry
|
|---|
| 105 | {
|
|---|
| 106 | QString filePath;
|
|---|
| 107 | int lineNo;
|
|---|
| 108 | int columnNo;
|
|---|
| 109 | };
|
|---|
| 110 |
|
|---|
| 111 | void emitMessage(MessageType type,
|
|---|
| 112 | const QString& message,
|
|---|
| 113 | const QString& details) const;
|
|---|
| 114 | QString toString() const;
|
|---|
| 115 | QString top() const;
|
|---|
| 116 |
|
|---|
| 117 | private:
|
|---|
| 118 | StackEntry stkBottom;
|
|---|
| 119 | QStack<StackEntry> *stk;
|
|---|
| 120 | StackEntry *stkTop;
|
|---|
| 121 | int stkDepth;
|
|---|
| 122 | bool etcetera;
|
|---|
| 123 |
|
|---|
| 124 | static int tabSize;
|
|---|
| 125 | static QString programName;
|
|---|
| 126 | static QRegExp *spuriousRegExp;
|
|---|
| 127 | };
|
|---|
| 128 |
|
|---|
| 129 | QT_END_NAMESPACE
|
|---|
| 130 |
|
|---|
| 131 | #endif
|
|---|