kiten/lib
indexedEDICTFile.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef KITEN_INDEXEDEDICTFILE_H
00022 #define KITEN_INDEXEDEDICTFILE_H
00023
00024 #include <QtCore/QFile>
00025 #include <QtCore/QString>
00026 #include <QtCore/QByteArray>
00027 #include <QtCore/QVector>
00028
00029 #ifdef HAVE_INTTYPES_H
00030 #include <inttypes.h>
00031 #else
00032 typedef unsigned int uint32_t;
00033 #endif
00034
00037 class indexedEDICTFile {
00038 public:
00040 indexedEDICTFile();
00041 ~indexedEDICTFile();
00043 bool loadFile(const QString &);
00045 bool valid() const;
00047 QVector<QString> findMatches(const QString &) const;
00048
00049 private:
00050 bool checkIndex() const;
00051 bool buildIndex();
00052 bool loadmmaps();
00053 uint32_t findFirstMatch(const QByteArray &) const;
00054
00055 QByteArray lookupFullLine(uint32_t i) const;
00056 QByteArray lookupDictLine(uint32_t i) const;
00057 unsigned char lookupDictChar(uint32_t i) const;
00058 int equalOrSubstring(const char *, const char *) const;
00059 int findMatches(const char*, const char*) const;
00060
00061
00062 bool m_valid;
00063 QFile m_dictFile;
00064 unsigned char* m_dictPtr;
00065 mutable QFile m_indexFile;
00066 uint32_t* m_indexPtr;
00067 static const int indexFileVersion = 14;
00068 };
00069
00070 #endif