Kate
prefixstore.h
Go to the documentation of this file.00001 /* 00002 * Copyright (C) 2009 by Michel Ludwig (michel.ludwig@kdemail.net) 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Library General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Library General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Library General Public License 00015 * along with this library; see the file COPYING.LIB. If not, write to 00016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 * Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef PREFIXSTORE_H 00021 #define PREFIXSTORE_H 00022 00023 #include <QHash> 00024 #include <QList> 00025 #include <QPair> 00026 #include <QSet> 00027 #include <QString> 00028 #include <QVector> 00029 00030 #include "katetextline.h" 00031 00040 class KatePrefixStore { 00041 public: 00042 typedef QPair<bool, bool> BooleanPair; 00043 00044 KatePrefixStore(); 00045 virtual ~KatePrefixStore(); 00046 00047 void addPrefix(const QString& prefix); 00048 void removePrefix(const QString& prefix); 00049 00054 QString findPrefix(const QString& s, int start = 0) const; 00055 00060 QString findPrefix(const KateTextLine::Ptr& line, int start = 0) const; 00061 00062 int longestPrefixLength() const; 00063 00064 void clear(); 00065 00066 void dump(); 00067 00068 protected: 00069 int m_longestPrefixLength; 00070 QSet<QString> m_prefixSet; 00071 00072 // State x Char -> Nr. of char occurrences in prefixes x State 00073 typedef QHash<unsigned short, QPair<unsigned int, unsigned long long> > CharToOccurrenceStateHash; 00074 typedef QHash<unsigned long long, CharToOccurrenceStateHash> TransitionFunction; 00075 TransitionFunction m_transitionFunction; 00076 QSet<unsigned long long> m_acceptingStates; 00077 QList<unsigned long long> m_stateFreeList; 00078 unsigned long long m_lastAssignedState; 00079 00080 int computeLongestPrefixLength(); 00081 unsigned long long nextFreeState(); 00082 // bool containsPrefixOfLengthEndingWith(int length, const QChar& c); 00083 }; 00084 00085 #endif 00086 00087 // kate: space-indent on; indent-width 2; replace-tabs on;
KDE 4.4 API Reference