From e9ae80694875f869892f13f4fcaf1170a00dea41 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdewebdev@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- quanta/parsers/parser.h | 160 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 quanta/parsers/parser.h (limited to 'quanta/parsers/parser.h') diff --git a/quanta/parsers/parser.h b/quanta/parsers/parser.h new file mode 100644 index 00000000..db797df0 --- /dev/null +++ b/quanta/parsers/parser.h @@ -0,0 +1,160 @@ +/*************************************************************************** + parser.h - description + ------------------- + begin : Sun Sep 1 2002 + copyright : (C) 2002, 2003, 2004 by Andras Mantia + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; version 2 of the License. * + * * + ***************************************************************************/ + +#ifndef PARSER_H +#define PARSER_H + +#include +#include +#include +#include +#include + +#include + +#include "node.h" +#include "tag.h" +#include "qtag.h" + +/** + *@author Andras Mantia + */ + +class Document; +class KDirWatch; +class QRegExp; +class NodeModifsSet; +class SAParser; + +typedef QMap IncludedGroupElements; +typedef QMap IncludedGroupElementsMap; + + +class Parser: public QObject { + +Q_OBJECT + +public: + Parser(); + ~Parser(); + + /** Parse a string, using as start position sLine, sCol. */ + Node *parseArea(int startLine, int startCol, int endLine, int endCol, Node **lastNode, Node *a_node = 0L); + + /** Parse the whole text from Document w and build the internal structure tree + from Nodes. Set force to true if you want to avoid the possible checks. */ + Node *parse(Document *w, bool force = false); + + /** Returns the node for position (line, column). As more than one node can + contain the same area, it return the "deepest" node. */ + Node *nodeAt(int line, int col, bool findDeepest = true, bool exact = false); + + /** Rebuild the nodes */ + Node *rebuild(Document *w); + /** No descriptions */ + const DTDStruct * currentDTD(int line, int col); + /** Remove the found groups from the memeber variables */ + void clearGroups(); + void parseIncludedFiles(); + + /** Enable/Disable parsing. */ + void setSAParserEnabled(bool enabled); + void setParsingEnabled(bool enabled) {m_parsingEnabled = enabled;} + bool isParsingEnabled() {return m_parsingEnabled;} + void setParsingNeeded(bool needed) {m_parsingNeeded = needed;} + bool parsingNeeded() {return m_parsingNeeded;} + /** + * This function is ESSENTIAL : when one modify baseNode, one MUST use + * this function to set the internal parser RootNode pointer to the same Node as + * baseNode. If one forget, some strange sigserv errors concerning inexisting tags + * (Node->tag == 0) will occurs. + * Crash errors of Parser::nodeAt is a good sign of a missing setRootNode + */ + void setRootNode(Node* node) {m_node = node;} //TODO: check if m_saParser should be updated or not! + void synchParseInDetail(); + + IncludedGroupElementsMap includedMap; + bool parsingEnabled; + bool m_treeReparsed; + +public slots: + void slotParseInDetail(); + /** Remove the found groups from the memeber variables */ + void cleanGroups(); + +private slots: + void slotIncludedFileChanged(const QString& fileName); + +signals: + void nodeTreeChanged(); + void rebuildStructureTree(bool); + +private: + Node* m_node; //the internal Node pointer + QString m_dtdName; //the DTD name of write + const DTDStruct* m_dtd; //the dtd used for main parsing + QGuardedPtr write; //pointer to the parsed document + int maxLines; // how many lines are in the current document + int oldMaxLines; + int treeSize; + QMap::ConstIterator xmlGroupIt; + bool m_parsingEnabled; + bool m_parsingNeeded; + + /** Clears the group elements found in the included files */ + void clearIncludedGroupElements(); + void parseIncludedFile(const QString &fileName, const DTDStruct *dtd); + /** Searches for scripts inside the text from startNode. It looks only for the + script begin/and delimiters, and not for the