The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
zstr.h
Go to the documentation of this file.
1 /*****************************************************************************
2  *
3  * zstr.h - class zStr: a helper class which provides support for
4  * compressed module drivers which use a string for their key
5  *
6  * $Id: zstr.h 3786 2020-08-30 11:35:14Z scribe $
7  *
8  * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
9  * CrossWire Bible Society
10  * P. O. Box 2528
11  * Tempe, AZ 85280-2528
12  *
13  * This program is free software; you can redistribute it and/or modify it
14  * under the terms of the GNU General Public License as published by the
15  * Free Software Foundation version 2.
16  *
17  * This program is distributed in the hope that it will be useful, but
18  * WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  * General Public License for more details.
21  *
22  */
23 
24 #ifndef ZSTR_H
25 #define ZSTR_H
26 
27 #include <defs.h>
28 
30 
31 class SWCompress;
32 class EntriesBlock;
33 class FileDesc;
34 class SWBuf;
35 
37 
38 private:
39  static int instance; // number of instantiated zStr objects or derivitives
41  mutable long cacheBlockIndex;
42  mutable bool cacheDirty;
43  char *path;
45  mutable long lastoff; // for caching and optimization
46  long blockCount;
48 
49 protected:
54  static const int IDXENTRYSIZE;
55  static const int ZDXENTRYSIZE;
56 
57  void getCompressedText(long block, long entry, char **buf) const;
58  void flushCache() const;
59  void getKeyFromDatOffset(long ioffset, char **buf) const;
60  void getKeyFromIdxOffset(long ioffset, char **buf) const;
61 
62 public:
63  zStr(const char *ipath, int fileMode = -1, long blockCount = 100, SWCompress *icomp = 0, bool caseSensitive = false);
64  virtual ~zStr();
65  signed char findKeyIndex(const char *ikey, long *idxoff, long away = 0) const;
66  void getText(long index, char **idxbuf, char **buf) const;
67  void setText(const char *ikey, const char *buf, long len = -1);
68  void linkEntry(const char *destkey, const char *srckey);
69  virtual void rawZFilter(SWBuf &buf, char direction = 0) const { (void) buf; (void) direction; }
70  static signed char createModule (const char *path);
71 };
72 
74 #endif
FileDesc * datfd
Definition: zstr.h:51
#define SWORD_NAMESPACE_START
Definition: defs.h:39
Definition: swbuf.h:47
#define SWDLLEXPORT
Definition: defs.h:171
SWCompress * compressor
Definition: zstr.h:47
FileDesc * idxfd
Definition: zstr.h:50
long cacheBlockIndex
Definition: zstr.h:41
static int instance
Definition: zstr.h:39
bool cacheDirty
Definition: zstr.h:42
static const int ZDXENTRYSIZE
Definition: zstr.h:55
char * path
Definition: zstr.h:43
static const int IDXENTRYSIZE
Definition: zstr.h:54
FileDesc * zdxfd
Definition: zstr.h:52
long lastoff
Definition: zstr.h:45
virtual void rawZFilter(SWBuf &buf, char direction=0) const
Definition: zstr.h:69
long blockCount
Definition: zstr.h:46
FileDesc * zdtfd
Definition: zstr.h:53
#define SWORD_NAMESPACE_END
Definition: defs.h:40
Definition: zstr.h:36
EntriesBlock * cacheBlock
Definition: zstr.h:40
bool caseSensitive
Definition: zstr.h:44