Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   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.5 2002/10/31 11:30:16 joachim 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 SWORD_NAMESPACE_START
00033 
00034 class SWCompress;
00035 class EntriesBlock;
00036 
00037 class SWDLLEXPORT zStr {
00038 
00039 private:
00040         static int instance;            // number of instantiated zStr objects or derivitives
00041         EntriesBlock *cacheBlock;
00042         long cacheBlockIndex;
00043         bool cacheDirty;
00044         char *path;
00045         long lastoff;
00046         long blockCount;
00047         SWCompress *compressor;
00048 
00049 protected:
00050         FileDesc *idxfd;
00051         FileDesc *datfd;
00052         FileDesc *zdxfd;
00053         FileDesc *zdtfd;
00054         static const int IDXENTRYSIZE;
00055         static const int ZDXENTRYSIZE;
00056 
00057         void getCompressedText(long block, long entry, char **buf);
00058         void flushCache();
00059         void prepText(char *buf);
00060         void getKeyFromDatOffset(long ioffset, char **buf);
00061         void getKeyFromIdxOffset(long ioffset, char **buf);
00062 
00063 public:
00064         char nl;
00065         zStr(const char *ipath, int fileMode = -1, long blockCount = 100, SWCompress *icomp = 0);
00066         virtual ~zStr();
00067         signed char findKeyIndex(const char *ikey, long *idxoff, long away = 0);
00068         void getText(long index, char **idxbuf, char **buf);
00069         void setText(const char *ikey, const char *buf, long len = -1);
00070         void linkEntry(const char *destkey, const char *srckey);
00071         virtual void rawZFilter(char *buf, long size, char direction = 0) {}
00072         static signed char createModule (const char *path);
00073 };
00074 
00075 SWORD_NAMESPACE_END
00076 #endif

Generated on Thu Oct 31 12:11:28 2002 for The Sword Project by doxygen1.2.17