summaryrefslogtreecommitdiff
path: root/library/qdawg.h
Unidiff
Diffstat (limited to 'library/qdawg.h') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qdawg.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/library/qdawg.h b/library/qdawg.h
new file mode 100644
index 0000000..ea182f3
--- a/dev/null
+++ b/library/qdawg.h
@@ -0,0 +1,70 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef QDAWG_H
21#define QDAWG_H
22
23#include <qstringlist.h>
24
25class QIODevice;
26class QDawgPrivate;
27
28class QDawg {
29public:
30 QDawg();
31 ~QDawg();
32
33 bool readFile(const QString&); // may mmap
34 bool read(QIODevice* dev);
35 bool write(QIODevice* dev) const;
36 bool createFromWords(QIODevice* dev);
37 void createFromWords(const QStringList&);
38 QStringList allWords() const;
39
40 bool contains(const QString&) const;
41 int countWords() const;
42
43 // Unicode 0..3FFF; an offset can be used for other ranges
44 static const int nodebits=18;
45
46 class Node {
47 friend class QDawgPrivate;
48 uint let:(30-nodebits);
49 uint isword:1;
50 uint islast:1;
51 int offset:nodebits;
52 Node() { }
53 public:
54 QChar letter() const { return QChar((ushort)let); }
55 bool isWord() const { return isword; }
56 bool isLast() const { return islast; }
57 const Node* next() const { return islast ? 0 : this+1; }
58 const Node* jump() const { return offset ? this+offset : 0; }
59 };
60
61 const Node* root() const;
62
63 void dump() const; // debug
64
65private:
66 friend class QDawgPrivate;
67 QDawgPrivate* d;
68};
69
70#endif