The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ztext4.h
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * ztext4.h - class zText4: a module driver which supports compressed
4  * Bibles supporting large 4 byte entry sizes
5  *
6  * $Id: ztext4.h 3786 2020-08-30 11:35:14Z scribe $
7  *
8  * Copyright 1996-2014 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 ZTEXT4_H
25 #define ZTEXT4_H
26 
27 #include <zverse4.h>
28 #include <swtext.h>
29 
30 #include <defs.h>
31 
32 
34 
35 /*** SWModule implementation for compressed modules
36 * This class handles compressed modules.
37 * It should not be used in frontends, unless you are doing very special things.
38 */
39 class SWDLLEXPORT zText4 : public zVerse4, public SWText {
40 
41 private:
43  bool sameBlock(VerseKey * lastWriteKey, VerseKey * key);
44  int blockType;
45 
46 public:
47  zText4(const char *ipath, const char *iname = 0, const char *idesc = 0,
48  int blockType = CHAPTERBLOCKS, SWCompress *icomp = 0,
49  SWDisplay *idisp = 0, SWTextEncoding encoding = ENC_UNKNOWN,
51  SWTextMarkup markup = FMT_UNKNOWN, const char *ilang = 0,
52  const char *versification = "KJV");
53 
54  virtual ~zText4();
55  virtual SWBuf &getRawEntryBuf() const;
56 
57  virtual void increment(int steps = 1);
58  virtual void decrement(int steps = 1) { increment(-steps); }
59 
60  // write interface ----------------------------
61  virtual bool isWritable() const;
62  static char createModule(const char *path, int blockBound, const char *v11n = "KJV") {
63  return zVerse4::createModule(path, blockBound, v11n);
64  }
65 
66  virtual void setEntry(const char *inbuf, long len = -1); // Modify current module entry
67  virtual void linkEntry(const SWKey *linkKey); // Link current module entry to other module entry
68  virtual void deleteEntry(); // Delete current module entry
69  // end write interface ------------------------
70 
71  virtual void rawZFilter(SWBuf &buf, char direction = 0) const { rawFilter(buf, (SWKey *)(long)direction); }// hack, use key as direction for enciphering
72 
73  // swcacher interface ----------------------
74  virtual void flush() { flushCache(); }
75  // end swcacher interface ----------------------
76 
77  virtual bool isLinked(const SWKey *k1, const SWKey *k2) const;
78  virtual bool hasEntry(const SWKey *k) const;
79 
81 };
82 
84 #endif
#define SWTextEncoding
Definition: swmodule.h:78
#define SWORD_NAMESPACE_START
Definition: defs.h:39
Definition: swbuf.h:47
Definition: swtext.h:36
#define SWDLLEXPORT
Definition: defs.h:171
Definition: ztext4.h:39
virtual void rawFilter(SWBuf &buf, const SWKey *key) const
Definition: swmodule.h:716
virtual void deleteEntry()
Definition: swmodule.h:525
virtual void setEntry(const char *inbuf, long len=-1)
Definition: swmodule.cpp:1680
SWBuf v11n
Definition: osis2mod.cpp:107
static char createModule(const char *path, int blockBound, const char *v11n="KJV")
Definition: zverse4.cpp:420
VerseKey * lastWriteKey
Definition: ztext4.h:42
#define CHAPTERBLOCKS
Definition: zverse.h:59
virtual bool isLinked(const SWKey *, const SWKey *) const
Definition: swmodule.h:808
virtual void linkEntry(const SWKey *sourceKey)
Definition: swmodule.cpp:1683
virtual bool isWritable() const
Definition: swmodule.h:506
virtual bool hasEntry(const SWKey *) const
Definition: swmodule.h:809
virtual void increment(int steps=1)
Definition: swmodule.cpp:355
int blockType
Definition: ztext4.h:44
virtual SWBuf & getRawEntryBuf() const =0
#define SWMODULE_OPERATORS
Definition: swmodule.h:54
virtual void flush()
Definition: ztext4.h:74
void flushCache() const
Definition: zverse4.cpp:337
#define SWTextDirection
Definition: swmodule.h:77
#define SWORD_NAMESPACE_END
Definition: defs.h:40
virtual void rawZFilter(SWBuf &buf, char direction=0) const
Definition: ztext4.h:71
virtual void decrement(int steps=1)
Definition: ztext4.h:58
Definition: swkey.h:77
static char createModule(const char *path, int blockBound, const char *v11n="KJV")
Definition: ztext4.h:62
#define SWTextMarkup
Definition: swmodule.h:79