[2] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
[846] | 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
[561] | 4 | ** All rights reserved.
|
---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
---|
[2] | 6 | **
|
---|
| 7 | ** This file is part of the tools applications of the Qt Toolkit.
|
---|
| 8 | **
|
---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
| 10 | ** Commercial Usage
|
---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
| 14 | ** a written agreement between you and Nokia.
|
---|
| 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 | **
|
---|
[561] | 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.
|
---|
[2] | 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 | **
|
---|
[561] | 36 | ** If you have questions regarding the use of this file, please contact
|
---|
| 37 | ** Nokia at [email protected].
|
---|
[2] | 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
|
---|