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