Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

zstr.h

00001 /*****************************************************************************
00002  * zstr.h   - code for class 'zStr'- a module that reads compressed text
00003  *                      files.
00004  *                      and provides lookup and parsing functions based on
00005  *                      class StrKey
00006  *
00007  * $Id: zstr_8h-source.html,v 1.3 2002/06/20 20:23:10 mgruner Exp $
00008  *
00009  * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)
00010  *      CrossWire Bible Society
00011  *      P. O. Box 2528
00012  *      Tempe, AZ  85280-2528
00013  *
00014  * This program is free software; you can redistribute it and/or modify it
00015  * under the terms of the GNU General Public License as published by the
00016  * Free Software Foundation version 2.
00017  *
00018  * This program is distributed in the hope that it will be useful, but
00019  * WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00021  * General Public License for more details.
00022  *
00023  */
00024 
00025 #ifndef ZSTR_H
00026 #define ZSTR_H
00027 
00028 #include <filemgr.h>
00029 
00030 #include <defs.h>
00031 
00032 class SWCompress;
00033 class EntriesBlock;
00034 
00035 class SWDLLEXPORT zStr {
00036 
00037 private:
00038         static int instance;            // number of instantiated zStr objects or derivitives
00039         EntriesBlock *cacheBlock;
00040         long cacheBlockIndex;
00041         bool cacheDirty;
00042         char *path;
00043         long lastoff;
00044         long blockCount;
00045         SWCompress *compressor;
00046 
00047 protected:
00048         FileDesc *idxfd;
00049         FileDesc *datfd;
00050         FileDesc *zdxfd;
00051         FileDesc *zdtfd;
00052         static const int IDXENTRYSIZE;
00053         static const int ZDXENTRYSIZE;
00054 
00055         void getCompressedText(long block, long entry, char **buf);
00056         void flushCache();
00057         void prepText(char *buf);
00058         void getKeyFromDatOffset(long ioffset, char **buf);
00059         void getKeyFromIdxOffset(long ioffset, char **buf);
00060 
00061 public:
00062         char nl;
00063         zStr(const char *ipath, int fileMode = -1, long blockCount = 100, SWCompress *icomp = 0);
00064         virtual ~zStr();
00065         signed char findKeyIndex(const char *ikey, long *idxoff, long away = 0);
00066         void getText(long index, char **idxbuf, char **buf);
00067         void setText(const char *ikey, const char *buf, long len = 0);
00068         void linkEntry(const char *destkey, const char *srckey);
00069         static signed char createModule (const char *path);
00070 };
00071 
00072 #endif

Generated on Thu Jun 20 22:13:01 2002 for The Sword Project by doxygen1.2.15