qdawg.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef QDAWG_H
00021 #define QDAWG_H
00022
00023 #include <qstringlist.h>
00024
00025 class QIODevice;
00026 class QDawgPrivate;
00027
00028 class QDawg {
00029 public:
00030 QDawg();
00031 ~QDawg();
00032
00033 bool readFile(const QString&);
00034 bool read(QIODevice* dev);
00035 bool write(QIODevice* dev) const;
00036 bool createFromWords(QIODevice* dev);
00037 void createFromWords(const QStringList&);
00038 QStringList allWords() const;
00039
00040 bool contains(const QString&) const;
00041 int countWords() const;
00042
00043
00044 static const int nodebits=18;
00045
00046 class Node {
00047 friend class QDawgPrivate;
00048 uint let:(30-nodebits);
00049 uint isword:1;
00050 uint islast:1;
00051 int offset:nodebits;
00052 Node() { }
00053 public:
00054 QChar letter() const { return QChar((ushort)let); }
00055 bool isWord() const { return isword; }
00056 bool isLast() const { return islast; }
00057 const Node* next() const { return islast ? 0 : this+1; }
00058 const Node* jump() const { return offset ? this+offset : 0; }
00059 };
00060
00061 const Node* root() const;
00062
00063 void dump() const;
00064
00065 private:
00066 friend class QDawgPrivate;
00067 QDawgPrivate* d;
00068 };
00069
00070 #endif
This file is part of the documentation for OPIE Version 1.5.5.