zverse.h

00001 /******************************************************************************
00002  *  rawverse.h   - code for class 'zVerse'- a module that reads raw text
00003  *                      files:  ot and nt using indexs ??.bks ??.cps ??.vss
00004  *                      and provides lookup and parsing functions based on
00005  *                      class VerseKey
00006  */
00007 
00008 #ifndef ZVERSE_H
00009 #define ZVERSE_H
00010 
00011 #include <defs.h>
00012 
00013 SWORD_NAMESPACE_START
00014 
00015 class FileDesc;
00016 class SWCompress;
00017 class SWBuf;
00018 
00019 class SWDLLEXPORT zVerse {
00020         SWCompress *compressor;
00021 
00022 protected:
00023         static int instance;            // number of instantiated zVerse objects or derivitives
00024 
00025         FileDesc *idxfp[2];
00026         FileDesc *textfp[2];
00027         FileDesc *compfp[2];
00028         char *path;
00029         void prepText(SWBuf &buf);
00030         void doSetText(char testmt, long idxoff, const char *buf, long len = 0);
00031         void doLinkEntry(char testmt, long destidxoff, long srcidxoff);
00032         void flushCache();
00033         char *cacheBuf;
00034         char cacheTestament;
00035         long cacheBufIdx;
00036         bool dirtyCache;
00037 
00038 public:
00039 
00040 #define VERSEBLOCKS 2
00041 #define CHAPTERBLOCKS 3
00042 #define BOOKBLOCKS 4
00043 
00044         static const char uniqueIndexID[];
00045         char nl;
00046 
00047 
00048         // fileMode default = RDONLY
00049         zVerse(const char *ipath, int fileMode = -1, int blockType = CHAPTERBLOCKS, SWCompress * icomp = 0);
00050         virtual ~zVerse();
00051 
00052         void findOffset(char testmt, long idxoff, long *start, unsigned short *end);
00053         void zReadText(char testmt, long start, unsigned short size, SWBuf &buf);
00054         virtual void rawZFilter(SWBuf &buf, char direction = 0) {}
00055         static char createModule(const char *path, int blockBound);
00056 };
00057 
00058 SWORD_NAMESPACE_END
00059 #endif