Qtopia library API Documentation

qdawg.h

00001 /**********************************************************************
00002 ** Copyright (C) 2000-2002 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of the Qtopia Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
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&); // may mmap
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     // Unicode 0..3FFF; an offset can be used for other ranges
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; // debug
00064 
00065 private:
00066     friend class QDawgPrivate;
00067     QDawgPrivate* d;
00068 };
00069 
00070 #endif
KDE Logo
This file is part of the documentation for OPIE Version 1.5.5.
Documentation copyright © 1997-2003 the KDE developers. 2003 OPIE developers
Generated on Tue Feb 10 20:24:06 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001