00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef ZSTR_H
00026 #define ZSTR_H
00027
00028 #include <defs.h>
00029
00030 SWORD_NAMESPACE_START
00031
00032 class SWCompress;
00033 class EntriesBlock;
00034 class FileDesc;
00035 class SWBuf;
00036
00037 class SWDLLEXPORT zStr {
00038
00039 private:
00040 static int instance;
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(SWBuf &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(SWBuf &buf, char direction = 0) {}
00072 static signed char createModule (const char *path);
00073 };
00074
00075 SWORD_NAMESPACE_END
00076 #endif