OSDN Git Service

It's 2011 now.
[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 (qt-info@nokia.com)
8 **
9 ** No Commercial Usage
10 **
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 **
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights.  These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
31 **
32 **************************************************************************/
33
34 #ifndef HIGHLIGHTDEFINITIONHANDLER_H
35 #define HIGHLIGHTDEFINITIONHANDLER_H
36
37 #include <QtCore/QString>
38 #include <QtCore/QList>
39 #include <QtCore/QSharedPointer>
40 #include <QtCore/QStack>
41
42 #include <QtXml/QXmlDefaultHandler>
43
44 namespace TextEditor {
45 namespace Internal {
46
47 class KeywordList;
48 class Context;
49 class Rule;
50 class HighlightDefinition;
51
52 class HighlightDefinitionHandler : public QXmlDefaultHandler
53 {
54 public:
55     HighlightDefinitionHandler(const QSharedPointer<HighlightDefinition> &definition);
56     ~HighlightDefinitionHandler();
57
58     bool startDocument();
59     bool endDocument();
60     bool startElement(const QString &namespaceURI, const QString &localName,
61                       const QString &qName, const QXmlAttributes &atts);
62     bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName);
63     bool characters(const QString &ch);
64
65 private:
66     void listElementStarted(const QXmlAttributes &atts);
67     void itemElementStarted();
68     void contextElementStarted(const QXmlAttributes &atts);
69     void itemDataElementStarted(const QXmlAttributes &atts) const;
70     void commentElementStarted(const QXmlAttributes &atts) const;
71     void keywordsElementStarted(const QXmlAttributes &atts) const;
72     void foldingElementStarted(const QXmlAttributes &atts) const;
73     void ruleElementStarted(const QXmlAttributes &atts, const QSharedPointer<Rule> &rule);
74
75     // Specific rules.
76     void detectCharStarted(const QXmlAttributes &atts);
77     void detect2CharsStarted(const QXmlAttributes &atts);
78     void anyCharStarted(const QXmlAttributes &atts);
79     void stringDetectedStarted(const QXmlAttributes &atts);
80     void regExprStarted(const QXmlAttributes &atts);
81     void keywordStarted(const QXmlAttributes &atts);
82     void intStarted(const QXmlAttributes &atts);
83     void floatStarted(const QXmlAttributes &atts);
84     void hlCOctStarted(const QXmlAttributes &atts);
85     void hlCHexStarted(const QXmlAttributes &atts);
86     void hlCStringCharStarted(const QXmlAttributes &atts);
87     void hlCCharStarted(const QXmlAttributes &atts);
88     void rangeDetectStarted(const QXmlAttributes &atts);
89     void lineContinue(const QXmlAttributes &atts);
90     void includeRulesStarted(const QXmlAttributes &atts);
91     void detectSpacesStarted(const QXmlAttributes &atts);
92     void detectIdentifier(const QXmlAttributes &atts);
93
94     void processIncludeRules() const;
95     void processIncludeRules(const QSharedPointer<Context> &context) const;
96
97     QSharedPointer<HighlightDefinition> m_definition;
98
99     bool m_processingKeyword;
100     QString m_currentKeyword;
101     QSharedPointer<KeywordList> m_currentList;
102     QSharedPointer<Context> m_currentContext;
103     QStack<QSharedPointer<Rule> > m_currentRule;
104
105     bool m_initialContext;
106 };
107
108 } // namespace Internal
109 } // namespace TextEditor
110
111 #endif // HIGHLIGHTDEFINITIONHANDLER_H