rawstr4.h

00001 /*****************************************************************************
00002  * rawstr.h   - code for class 'RawStr'- 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 StrKey
00006  *
00007  * $Id: rawstr4.h 1864 2005-11-20 06:06:40Z scribe $
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 RAWSTR4_H
00026 #define RAWSTR4_H
00027 
00028 #include <defs.h>
00029 
00030 SWORD_NAMESPACE_START
00031 
00032 class FileDesc;
00033 class SWBuf;
00034 
00035 class SWDLLEXPORT RawStr4 {
00036         static int instance;            // number of instantiated RawStr4 objects or derivitives
00037         char *path;
00038         long lastoff;
00039 
00040 protected:
00041         FileDesc *idxfd;
00042         FileDesc *datfd;
00043         void prepText(SWBuf &buf);
00044         void doSetText(const char *key, const char *buf, long len = -1);
00045         void doLinkEntry(const char *destkey, const char *srckey);
00046 public:
00047         char nl;
00048         RawStr4(const char *ipath, int fileMode = -1);
00049         virtual ~RawStr4();
00050         void getIDXBuf(long ioffset, char **buf);
00051         void getIDXBufDat(long ioffset, char **buf);
00052         signed char findOffset(const char *key, long *start, unsigned long *size,
00053         long away = 0, long *idxoff = 0);
00054         void readText(long start, unsigned long *size, char **idxbuf, SWBuf &buf);
00055         static signed char createModule(const char *path);
00056 };
00057 
00058 SWORD_NAMESPACE_END
00059 #endif