OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / texteditor / generichighlighter / highlightdefinitionhandler.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 **
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 **
23 ** Other Usage
24 **
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
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 #ifndef HIGHLIGHTDEFINITIONHANDLER_H
34 #define HIGHLIGHTDEFINITIONHANDLER_H
35
36 #include <QtCore/QString>
37 #include <QtCore/QList>
38 #include <QtCore/QSharedPointer>
39 #include <QtCore/QStack>
40
41 #include <QtXml/QXmlDefaultHandler>
42
43 namespace TextEditor {
44 namespace Internal {
45
46 class KeywordList;
47 class Context;
48 class Rule;
49 class HighlightDefinition;
50
51 class HighlightDefinitionHandler : public QXmlDefaultHandler
52 {
53 public:
54     HighlightDefinitionHandler(const QSharedPointer<HighlightDefinition> &definition);
55     ~HighlightDefinitionHandler();
56
57     bool startDocument();
58     bool endDocument();
59     bool startElement(const QString &namespaceURI, const QString &localName,
60                       const QString &qName, const QXmlAttributes &atts);
61     bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName);
62     bool characters(const QString &ch);
63
64 private:
65     void listElementStarted(const QXmlAttributes &atts);
66     void itemElementStarted();
67     void contextElementStarted(const QXmlAttributes &atts);
68     void itemDataElementStarted(const QXmlAttributes &atts) const;
69     void commentElementStarted(const QXmlAttributes &atts) const;
70     void keywordsElementStarted(const QXmlAttributes &atts) const;
71     void foldingElementStarted(const QXmlAttributes &atts) const;
72     void ruleElementStarted(const QXmlAttributes &atts, const QSharedPointer<Rule> &rule);
73
74     // Specific rules.
75     void detectCharStarted(const QXmlAttributes &atts);
76     void detect2CharsStarted(const QXmlAttributes &atts);
77     void anyCharStarted(const QXmlAttributes &atts);
78     void stringDetectedStarted(const QXmlAttributes &atts);
79     void regExprStarted(const QXmlAttributes &atts);
80     void keywordStarted(const QXmlAttributes &atts);
81     void intStarted(const QXmlAttributes &atts);
82     void floatStarted(const QXmlAttributes &atts);
83     void hlCOctStarted(const QXmlAttributes &atts);
84     void hlCHexStarted(const QXmlAttributes &atts);
85     void hlCStringCharStarted(const QXmlAttributes &atts);
86     void hlCCharStarted(const QXmlAttributes &atts);
87     void rangeDetectStarted(const QXmlAttributes &atts);
88     void lineContinue(const QXmlAttributes &atts);
89     void includeRulesStarted(const QXmlAttributes &atts);
90     void detectSpacesStarted(const QXmlAttributes &atts);
91     void detectIdentifier(const QXmlAttributes &atts);
92
93     void processIncludeRules() const;
94     void processIncludeRules(const QSharedPointer<Context> &context) const;
95
96     QSharedPointer<HighlightDefinition> m_definition;
97
98     bool m_processingKeyword;
99     QString m_currentKeyword;
100     QSharedPointer<KeywordList> m_currentList;
101     QSharedPointer<Context> m_currentContext;
102     QStack<QSharedPointer<Rule> > m_currentRule;
103
104     bool m_initialContext;
105 };
106
107 } // namespace Internal
108 } // namespace TextEditor
109
110 #endif // HIGHLIGHTDEFINITIONHANDLER_H