[sword-cvs] sword/include ztext2.h,NONE,1.1 zverse2.h,NONE,1.1
sword@www.crosswire.org
sword@www.crosswire.org
Tue, 13 Apr 2004 16:41:42 -0700
Update of /cvs/core/sword/include
In directory www:/tmp/cvs-serv19023
Added Files:
ztext2.h zverse2.h
Log Message:
dglassey: remember to commit these
--- NEW FILE: ztext2.h ---
/******************************************************************************
* ztext.h - code for class 'zText2'- a module that reads compressed text
* files: ot and nt using indexs ??.vss
*
* $Id: ztext2.h,v 1.1 2004/04/13 23:41:40 dglassey Exp $
*
* Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation version 2.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
*/
#ifndef ZTEXT_H
#define ZTEXT_H
#include <zverse2.h>
#include <versekey2.h>
#include <rawstr.h>
#include <swtext.h>
//#include <swcomprs.h>
#include <defs.h>
namespace lucene { namespace index {
class IndexReader;
}}
namespace lucene { namespace search {
class IndexSearcher;
}}
SWORD_NAMESPACE_START
/*** SWModule implementation for compressed modules
* This class handles compressed modules.
* It should not be used in frontends, unless you are doing very special things.
*/
class SWDLLEXPORT zText2:public zVerse2, public SWText {
VerseKey2 *lastWriteKey;
bool sameBlock(VerseKey2 * lastWriteKey, VerseKey2 * key);
int blockType;
lucene::index::IndexReader *ir;
lucene::search::IndexSearcher *is;
VerseKey2 &getVerseKey();
public:
zText2(const char *ipath, const char *iname = 0, const char *idesc = 0,
int blockType = CHAPTERBLOCKS, int idxPerBlock = 10,
SWCompress * icomp = 0,
SWDisplay * idisp = 0, SWTextEncoding encoding = ENC_UNKNOWN,
SWTextDirection dir = DIRECTION_LTR,
SWTextMarkup markup = FMT_UNKNOWN, const char* ilang = 0);
virtual ~zText2();
#if 0
virtual SWBuf &getRawEntryBuf();
#endif
virtual void increment(int steps = 1);
virtual void decrement(int steps = 1) { increment(-steps); }
// write interface ----------------------------
virtual bool isWritable() { return ((idxfp->getFd() > 0) && ((idxfp->mode & O_RDWR) == O_RDWR)); }
static char createModule(const char *path, int blockBound, int indxPerBlock) {
return zVerse2::createModule(path, blockBound, indxPerBlock);
}
virtual void setEntry(const char *inbuf, long len = -1); // Modify current module entry
virtual void linkEntry(const SWKey *linkKey); // Link current module entry to other module entry
virtual void deleteEntry(); // Delete current module entry
// end write interface ------------------------
virtual void rawZFilter(SWBuf &buf, char direction = 0) { rawFilter(buf, (SWKey *)(long)direction); }// hack, use key as direction for enciphering
// swcacher interface ----------------------
virtual void flush() { flushCache(); }
// end swcacher interface ----------------------
virtual signed char createSearchFramework();
virtual bool hasSearchFramework() { return true; }
virtual ListKey &search(const char *istr, int searchType = 0, int flags = 0, SWKey * scope = 0, bool * justCheckIfSupported = 0, void (*percent)(char, void *) = &SWModule::nullPercent, void *percentUserData = 0);
SWMODULE_OPERATORS
};
SWORD_NAMESPACE_END
#endif
--- NEW FILE: zverse2.h ---
/******************************************************************************
* zverse2.h - code for class 'zVerse2'- a module that reads raw text
* files: text using indexs ??.bks ??.cps ??.vss
* and provides lookup and parsing functions based on
* class VerseKey2
*/
#ifndef ZVERSE_H
#define ZVERSE_H
#include <filemgr.h>
#include <fcntl.h>
//#include <rawverse.h>
#include <swcomprs.h>
#include <defs.h>
SWORD_NAMESPACE_START
class SWDLLEXPORT zVerse2 {
SWCompress *compressor;
protected:
static int instance; // number of instantiated zVerse2 objects or derivitives
FileDesc *idxfp;
FileDesc *textfp;
FileDesc *compfp;
FileDesc *markupfp;
FileDesc *midxfp;
char *path;
#if 0
void prepText(SWBuf &buf);
#endif
void doSetText(long idxoff, const char *buf, long len = 0);
void doLinkEntry(long destidxoff, long srcidxoff);
void flushCache();
char *cacheBuf;
long cacheBufIdx;
bool dirtyCache;
int m_idxPerBlock;
public:
#define VERSEBLOCKS 2
#define CHAPTERBLOCKS 3
#define BOOKBLOCKS 4
#define INDEXBLOCKS 5
static const char uniqueIndexID[];
char nl;
zVerse2(const char *ipath, int fileMode = O_RDONLY, int blockType = CHAPTERBLOCKS,
SWCompress * icomp = 0, int indexesPerBlock = 10);
virtual ~zVerse2();
void findOffsetText(long idxoff, long *start, unsigned short *end);
void findOffsetMarkup(long idxoff, long *start, unsigned short *end);
void zReadText(long start, unsigned short size, SWBuf &buf);
#if 0
virtual void rawZFilter(SWBuf &buf, char direction = 0) {}
#endif
static char createModule(const char *path, int blockBound, int indxPerBlock);
};
SWORD_NAMESPACE_END
#endif