• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

Kate

  • kde-4.14
  • applications
  • kate
  • part
  • spellcheck
prefixstore.h
Go to the documentation of this file.
1 /* This file is part of the KDE libraries and the Kate part.
2  *
3  * Copyright (C) 2008-2009 by Michel Ludwig <michel.ludwig@kdemail.net>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB. If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef PREFIXSTORE_H
22 #define PREFIXSTORE_H
23 
24 #include <QHash>
25 #include <QList>
26 #include <QPair>
27 #include <QSet>
28 #include <QString>
29 #include <QVector>
30 
31 #include "katetextline.h"
32 
41 class KatePrefixStore {
42  public:
43  typedef QPair<bool, bool> BooleanPair;
44 
45  KatePrefixStore();
46  virtual ~KatePrefixStore();
47 
48  void addPrefix(const QString& prefix);
49  void removePrefix(const QString& prefix);
50 
55  QString findPrefix(const QString& s, int start = 0) const;
56 
61  QString findPrefix(const Kate::TextLine& line, int start = 0) const;
62 
63  int longestPrefixLength() const;
64 
65  void clear();
66 
67  void dump();
68 
69  protected:
70  int m_longestPrefixLength;
71  QSet<QString> m_prefixSet;
72 
73  // State x Char -> Nr. of char occurrences in prefixes x State
74  typedef QHash<unsigned short, QPair<unsigned int, unsigned long long> > CharToOccurrenceStateHash;
75  typedef QHash<unsigned long long, CharToOccurrenceStateHash> TransitionFunction;
76  TransitionFunction m_transitionFunction;
77  QSet<unsigned long long> m_acceptingStates;
78  QList<unsigned long long> m_stateFreeList;
79  unsigned long long m_lastAssignedState;
80 
81  int computeLongestPrefixLength();
82  unsigned long long nextFreeState();
83 // bool containsPrefixOfLengthEndingWith(int length, const QChar& c);
84 };
85 
86 #endif
87 
88 // kate: space-indent on; indent-width 2; replace-tabs on;
KatePrefixStore::m_transitionFunction
TransitionFunction m_transitionFunction
Definition: prefixstore.h:76
KatePrefixStore
This class can be used to efficiently search for occurrences of strings in a given string...
Definition: prefixstore.h:41
katetextline.h
KatePrefixStore::longestPrefixLength
int longestPrefixLength() const
Definition: prefixstore.cpp:158
KatePrefixStore::m_longestPrefixLength
int m_longestPrefixLength
Definition: prefixstore.h:70
KatePrefixStore::BooleanPair
QPair< bool, bool > BooleanPair
Definition: prefixstore.h:43
KatePrefixStore::clear
void clear()
Definition: prefixstore.cpp:163
KatePrefixStore::TransitionFunction
QHash< unsigned long long, CharToOccurrenceStateHash > TransitionFunction
Definition: prefixstore.h:75
KatePrefixStore::m_stateFreeList
QList< unsigned long long > m_stateFreeList
Definition: prefixstore.h:78
KatePrefixStore::removePrefix
void removePrefix(const QString &prefix)
Definition: prefixstore.cpp:70
KatePrefixStore::KatePrefixStore
KatePrefixStore()
Definition: prefixstore.cpp:27
QSharedPointer
QHash
KatePrefixStore::nextFreeState
unsigned long long nextFreeState()
Definition: prefixstore.cpp:184
QSet< QString >
QString
QList< unsigned long long >
KatePrefixStore::m_lastAssignedState
unsigned long long m_lastAssignedState
Definition: prefixstore.h:79
QPair
KatePrefixStore::dump
void dump()
Definition: prefixstore.cpp:109
KatePrefixStore::addPrefix
void addPrefix(const QString &prefix)
Definition: prefixstore.cpp:37
KatePrefixStore::computeLongestPrefixLength
int computeLongestPrefixLength()
Definition: prefixstore.cpp:173
KatePrefixStore::m_acceptingStates
QSet< unsigned long long > m_acceptingStates
Definition: prefixstore.h:77
KatePrefixStore::CharToOccurrenceStateHash
QHash< unsigned short, QPair< unsigned int, unsigned long long > > CharToOccurrenceStateHash
Definition: prefixstore.h:74
KatePrefixStore::findPrefix
QString findPrefix(const QString &s, int start=0) const
Returns the shortest prefix of the given string that is contained in this prefix store starting at po...
Definition: prefixstore.cpp:120
KatePrefixStore::~KatePrefixStore
virtual ~KatePrefixStore()
Definition: prefixstore.cpp:33
KatePrefixStore::m_prefixSet
QSet< QString > m_prefixSet
Definition: prefixstore.h:71
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:59 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Kate

Skip menu "Kate"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal