ztext.h

00001 /******************************************************************************
00002  *  ztext.h   - code for class 'zText'- a module that reads compressed text
00003  *                              files: ot and nt using indexs ??.vss
00004  *
00005  * $Id: ztext.h 1864 2005-11-20 06:06:40Z scribe $
00006  *
00007  * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)
00008  *      CrossWire Bible Society
00009  *      P. O. Box 2528
00010  *      Tempe, AZ  85280-2528
00011  *
00012  * This program is free software; you can redistribute it and/or modify it
00013  * under the terms of the GNU General Public License as published by the
00014  * Free Software Foundation version 2.
00015  *
00016  * This program is distributed in the hope that it will be useful, but
00017  * WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019  * General Public License for more details.
00020  *
00021  */
00022 
00023 #ifndef ZTEXT_H
00024 #define ZTEXT_H
00025 
00026 #include <zverse.h>
00027 #include <swtext.h>
00028 
00029 #include <defs.h>
00030 
00031 namespace lucene { namespace index {
00032 class IndexReader;
00033 }}
00034 
00035 namespace lucene { namespace search {
00036 class IndexSearcher;
00037 }}
00038 
00039 SWORD_NAMESPACE_START
00040 
00041 /*** SWModule implementation for compressed modules
00042 * This class handles compressed modules.
00043 * It should not be used in frontends, unless you are doing very special things.
00044 */
00045 class SWDLLEXPORT zText:public zVerse, public SWText {
00046 
00047         VerseKey *lastWriteKey;
00048         bool sameBlock(VerseKey * lastWriteKey, VerseKey * key);
00049         int blockType;
00050 
00051 
00052 public:
00053     
00054         zText(const char *ipath, const char *iname = 0, const char *idesc = 0,
00055                         int blockType = CHAPTERBLOCKS, SWCompress * icomp = 0,
00056                         SWDisplay * idisp = 0, SWTextEncoding encoding = ENC_UNKNOWN,
00057                         SWTextDirection dir = DIRECTION_LTR,
00058                         SWTextMarkup markup = FMT_UNKNOWN, const char* ilang = 0);
00059 
00060         virtual ~zText();
00061         virtual SWBuf &getRawEntryBuf();
00062 
00063         virtual void increment(int steps = 1);
00064         virtual void decrement(int steps = 1) { increment(-steps); }
00065 
00066   // write interface ----------------------------
00067         virtual bool isWritable();
00068         static char createModule(const char *path, int blockBound) {
00069                 return zVerse::createModule(path, blockBound);
00070         }
00071 
00072      virtual void setEntry(const char *inbuf, long len = -1);   // Modify current module entry
00073      virtual void linkEntry(const SWKey *linkKey);      // Link current module entry to other module entry
00074         virtual void deleteEntry();     // Delete current module entry
00075   // end write interface ------------------------
00076   
00077         virtual void rawZFilter(SWBuf &buf, char direction = 0) { rawFilter(buf, (SWKey *)(long)direction); }// hack, use key as direction for enciphering
00078 
00079         // swcacher interface ----------------------
00080         virtual void flush() { flushCache(); }
00081         // end swcacher interface ----------------------
00082 
00083         SWMODULE_OPERATORS
00084 
00085 };
00086 
00087 SWORD_NAMESPACE_END
00088 #endif