[sword-cvs] sword/include refsysmgr.h, NONE, 1.1 refsys.h, NONE,
1.1 kjvref.h, NONE, 1.1 versekey2.h, 1.5, 1.6 ztext2.h, 1.1,
1.2 zverse2.h, 1.1, 1.2 osisbook.h, 1.5, 1.6
sword at www.crosswire.org
sword at www.crosswire.org
Fri May 7 10:02:34 MST 2004
Update of /cvs/core/sword/include
In directory www:/tmp/cvs-serv6501
Modified Files:
versekey2.h ztext2.h zverse2.h osisbook.h
Added Files:
refsysmgr.h refsys.h kjvref.h
Log Message:
dglassey: proof of concept versification system
RefSys provides the reference system for VerseKey2
RefSysMgr manages and loads the RefSys from data and conf files
--- NEW FILE: refsysmgr.h ---
/******************************************************************************
* refsysmgr.h - definition of class RefSysMgr used to interact with
* registered biblical reference systems for a sword installation
*
* $Id: refsysmgr.h,v 1.1 2004/05/07 17:02:32 dglassey Exp $
*
* Copyright 2004 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 REFSYSMGR_H
#define REFSYSMGR_H
#include <map>
#include <list>
//#include <swconfig.h>
#include <defs.h>
SWORD_NAMESPACE_START
class RefSys;
class VerseKey2;
#if 0
struct RefDetails
{
char *name;
int cpssize;
};
#endif
typedef std::pair <RefSys *, int> RefDetails;
typedef std::list<SWBuf> StringList;
typedef std::map < SWBuf, RefDetails, std::less < SWBuf > > RefSysMap;
/**
* The RefSysMgr class handles all the different locales of Sword.
* It provides functions to get a list of all available locales,
* to get the default locale name and to get it.
* The other functions are not interesting for frontend programmers.
*
* To get the default locale name use @see getDefaultLocaleName
* To set the default locale name use @see setDefaultLocaleName
* To get the locale for a language name use @see getLocale
* To get a list of availble locales use @see getAvailableLocales
*/
class SWDLLEXPORT RefSysMgr {
private:
void deleteRefSys();
char *defaultRefSysName;
RefSysMgr(const RefSysMgr &);
friend class __staticsystemRefSysMgr;
RefSys *loadRefSys(const char *name, int cpssize);
SWBuf refpath;
protected:
RefSysMap *m_reflist;
static RefSysMgr *systemRefSysMgr;
public:
/** Default constructor of RefSysMgr
* You do normally not need this constructor, use RefSysMgr::getSystemRefSysMgr() instead.
*/
RefSysMgr(const char *iConfigPath = 0);
/**
* Default destructor of RefSysMgr
*/
virtual ~RefSysMgr();
/** Get the locale connected with the name "name".
*
* @param name The name of the locale you want to have. For example use getLocale("de") to get the locale for the German language.
* @return Returns the locale object if the locale with the name given as parameter was found. If it wasn't found return NULL.
*/
virtual RefSys *getRefSys(const char *name);
virtual VerseKey2 *getVerseKey(const char *name, const char *key);
/** Get the list of available locales.
*
* @return Returns a list of strings, which contains the names of the available locales.
*/
virtual StringList getAvailableRefSys();
/** Get the default locale name. To set it use @see setDefaultLocaleName
*
* @return Returns the default locale name
*/
virtual const char *getDefaultRefSysName();
/** Set the new standard locale of Sword.
*
* @param name The name of the new default locale
*/
virtual void setDefaultRefSysName(const char *name);
/** The RefSysMgr object used globally in the Sword world.
* Do not create your own RefSysMgr, use this static object instead.
*/
static RefSysMgr *getSystemRefSysMgr();
static void setSystemRefSysMgr(RefSysMgr *newRefSysMgr);
/** Augment this localmgr with all locale.conf files in a directory
*/
virtual void loadConfigDir(const char *ipath);
};
SWORD_NAMESPACE_END
#endif
--- NEW FILE: refsys.h ---
/******************************************************************************
* refsys.h - code for class 'refsys'- Biblical reference system
*
* $Id: refsys.h,v 1.1 2004/05/07 17:02:32 dglassey Exp $
*
* Copyright 2004 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 REFSYS_H
#define REFSYS_H
#include <defs.h>
SWORD_NAMESPACE_START
#define OTBOOKS 39
#define NTBOOKS 27
#define MAXOSISBOOKS 93
#define TESTAMENT_HEADING 255
#define NOTINREFSYS -1
struct bkref
{
long offset;
unsigned char maxnext;
};
class SWDLLEXPORT RefSys
{
const bkref *m_offsets[2];
int m_offsize[2];
char *m_name;
//static bkref kjvbks[];
//static bkref kjvcps[];
/** Binary search to find the index closest, but less
* than the given value.
*
* @param array long * to array to search
* @param size number of elements in the array
* @param value value to find
* @return the index into the array that is less than but closest to value
*/
int findindex(const bkref *array, int size, long value) const;
public:
RefSys(const char *name,
const bkref *offsets[2] = 0,
const int offsize[2] = 0
);
~RefSys();
virtual const int getMaxChaptersInBook(char book) const;
virtual const int getMaxVerseInChapter(char book, int chapter) const;
void getBCV(long iindex, char *book, int *chapter, int *verse) const;
const long getIndex(char book, int chapter, int verse) const;
const bool isBookInRefSys(char book) const;
const char *getName() const {return m_name;}
};
SWORD_NAMESPACE_END
#endif
--- NEW FILE: kjvref.h ---
/******************************************************************************
* kjvref.h - KJV versification used as default by Sword
*
* $Id: kjvref.h,v 1.1 2004/05/07 17:02:32 dglassey Exp $
*
* Copyright 2004 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.
*
[...1385 lines suppressed...]
{32119, 19}, // Revelation of John:11
{32139, 17}, // Revelation of John:12
{32157, 18}, // Revelation of John:13
{32176, 20}, // Revelation of John:14
{32197, 8}, // Revelation of John:15
{32206, 21}, // Revelation of John:16
{32228, 18}, // Revelation of John:17
{32247, 24}, // Revelation of John:18
{32272, 21}, // Revelation of John:19
{32294, 15}, // Revelation of John:20
{32310, 27}, // Revelation of John:21
{32338, 21} // Revelation of John:22
};
#if 0
int
RefSys::offsize[2] =
{ NTBOOKS+OTBOOKS+3, sizeof (RefSys::kjvcps) / sizeof(bkref)
};
#endif
Index: versekey2.h
===================================================================
RCS file: /cvs/core/sword/include/versekey2.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- versekey2.h 29 Apr 2004 15:59:54 -0000 1.5
+++ versekey2.h 7 May 2004 17:02:32 -0000 1.6
@@ -27,7 +27,7 @@
#include <swmacs.h>
#include <listkey.h>
#include <ctype.h>
-
+#include <refsys.h>
#include <defs.h>
SWORD_NAMESPACE_START
@@ -42,11 +42,9 @@
#define KEYERR_FAILEDPARSE 2
-struct bkref
-{
- long offset;
- unsigned char maxnext;
-};
+#define GENESIS 2
+#define REVELATION 93
+#define MAXOSISBOOKS 93
struct sbook2
@@ -58,13 +56,6 @@
/**Preferred Abbreviation
*/
const char *prefAbbrev;
-
- /**Maximum chapters in book
- */
- //unsigned char chapmax;
- /** Array[chapmax] of maximum verses in chapters
- */
- //const bkref *versemax;
};
struct abbrev2
@@ -85,56 +76,45 @@
class LocaleCache {
public:
char *name;
+ char *refsys;
unsigned int abbrevsCnt;
+ struct abbrev2 *abbrevs;
SWLocale *locale;
- LocaleCache() : name(0), abbrevsCnt(0), locale(0) {};
+ LocaleCache() : name(0), refsys(0), abbrevsCnt(0), abbrevs(0), locale(0) {};
virtual ~LocaleCache() {
if (name)
delete[]name;
+ if (refsys)
+ delete[]refsys;
+ if (abbrevs)
+ delete[] abbrevs;
}
};
static SWClass classdef;
- //static long *offsets[2][2];
- static bkref *offsets[2];
- //static int offsize[2][2];
- static int offsize[2];
+ static struct sbook2 osisbooks[];
/** number of instantiated VerseKey2 objects or derivitives
*/
static int instance;
-/* static struct sbook otbooks[];
- static struct sbook ntbooks[];
- static long otbks[];
- static long otcps[];
- static long ntbks[];
- static long ntcps[];
- static int vm[];
-*/
- static struct sbook2 osisbooks[];
- static bkref kjvbks[];
- static bkref kjvcps[];
static LocaleCache *localeCache;
ListKey internalListKey;
+ const RefSys *m_refsys;
const struct abbrev2 *abbrevs;
char *locale;
int abbrevsCnt;
/** The Testament: 0 - Old; 1 - New
*/
- //signed char testament;
- mutable signed char book;
- mutable signed int chapter;
- mutable signed int verse;
+ mutable char book;
+ mutable int chapter;
+ mutable int verse;
/** flag for auto normalization
*/
char autonorm;
/** flag for headings on/off
*/
char headings;
- /** flag to use old ot/nt indexes for old modules
- */
- //bool oldindexhack;
int getBookAbbrev(const char *abbr);
void initBounds() const;
@@ -153,33 +133,26 @@
*
*/
virtual char parse();
- /** Binary search to find the index closest, but less
- * than the given value.
- *
- * @param array long * to array to search
- * @param size number of elements in the array
- * @param value value to find
- * @return the index into the array that is less than but closest to value
- */
- int findindex(bkref *array, int size, long value);
mutable VerseKey2 *lowerBound, *upperBound;
-
- static const char builtin_BMAX;
- //static struct sbook *builtin_books[2];
static struct sbook2 *builtin_books;
- static const struct abbrev2 builtin_abbrevs[];
- const char *BMAX;
struct sbook2 **books;
public:
- //static const char builtin_BMAX[2];
+ /**
+ * VerseKey2 Constructor - initializes Instance of VerseKey2
+ *
+ * @param ikey text key (will take various forms of 'BOOK CH:VS'.
+ * See parse() for more detailed information)
+ */
+ //VerseKey2(const char *ikey = 0);
/**
* VerseKey2 Constructor - initializes Instance of VerseKey2
*
* @param ikey text key (will take various forms of 'BOOK CH:VS'.
* See parse() for more detailed information)
+ * @param ref Reference system to use for the key
*/
- VerseKey2(const char *ikey = 0);
+ VerseKey2(const char *ikey = 0, const RefSys *ref=0);
/**
* VerseKey2 Constructor - initializes instance of VerseKey2
@@ -250,7 +223,7 @@
*/
virtual const char *getText() const;
virtual const char *getShortText() const;
- virtual void setText(const char *ikey) { SWKey::setText(ikey); parse (); }
+ virtual void setText(const char *ikey) { printf("VerseKey2::setText %s\n", ikey);SWKey::setText(ikey); parse (); }
virtual void copyFrom(const SWKey & ikey);
/** Equates this VerseKey2 to another VerseKey2
@@ -281,11 +254,6 @@
virtual const char *getBookName() const;
virtual const char *getBookAbbrev() const;
- /** Gets testament
- *
- * @return value of testament
- */
- //virtual char Testament() const;
/** Gets book
*
@@ -304,16 +272,7 @@
* @return value of verse
*/
virtual int Verse() const;
-
- /** Sets/gets testament
- *
- * @param itestament value which to set testament
- * [MAXPOS(char)] - only get
- * @return if unchanged -> value of testament,
- * if changed -> previous value of testament
- */
- //virtual char Testament(char itestament);
-
+
/** Sets/gets book
*
* @param ibook value which to set book
@@ -385,12 +344,15 @@
virtual long Index(long iindex);
virtual const char *getOSISRef() const;
+ static const int getOSISBookNum(const char *bookab);
+ #if 0
virtual const char getMaxBooks() const;
- virtual const char *getNameOfBook(char book) const;
- virtual const char *getPrefAbbrev(char book) const;
- virtual const int getMaxChaptersInBook(char book) const;
- virtual const int getMaxVerseInChapter(char book, int chapter) const;
+ #endif
+ virtual const char *getNameOfBook(char cBook) const;
+ virtual const char *getPrefAbbrev(char cBook) const;
+ virtual const int getMaxChaptersInBook(char cBook) const;
+ virtual const int getMaxVerseInChapter(char cBook, int iChapter) const;
virtual ListKey ParseVerseList(const char *buf, const char *defaultKey = "Genesis 1:1", bool expandRange = false);
virtual const char *getRangeText() const;
@@ -412,10 +374,12 @@
*/
virtual int _compare(const VerseKey2 & ikey);
- virtual void setBookAbbrevs(const struct abbrev2 *bookAbbrevs, unsigned int size = 0 /* default determine size */ );
- virtual void setBooks(const char *iBMAX, struct sbook2 **ibooks);
+ virtual void setBookAbbrevs(const struct abbrev2 *bookAbbrevs);
+ virtual void setBooks(struct sbook2 **ibooks);
virtual void setLocale(const char *name);
virtual const char *getLocale() const { return locale; }
+ virtual void setRefSys(const char *name);
+ virtual const char *getRefSys() const { return m_refsys->getName(); }
@@ -425,6 +389,7 @@
SWKEY_OPERATORS
virtual SWKey & operator = (const VerseKey2 & ikey) { copyFrom(ikey); return *this; }
+ bool operator ==(const VerseKey2 & ikey) { return !_compare(ikey); } \
};
#ifdef VK2
Index: ztext2.h
===================================================================
RCS file: /cvs/core/sword/include/ztext2.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ztext2.h 13 Apr 2004 23:41:40 -0000 1.1
+++ ztext2.h 7 May 2004 17:02:32 -0000 1.2
@@ -20,8 +20,8 @@
*
*/
-#ifndef ZTEXT_H
-#define ZTEXT_H
+#ifndef ZTEXT2_H
+#define ZTEXT2_H
#include <zverse2.h>
#include <versekey2.h>
@@ -66,16 +66,14 @@
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) {
+ static char createModule(const char *path, int blockBound, int indxPerBlock = 10) {
return zVerse2::createModule(path, blockBound, indxPerBlock);
}
Index: zverse2.h
===================================================================
RCS file: /cvs/core/sword/include/zverse2.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- zverse2.h 13 Apr 2004 23:41:40 -0000 1.1
+++ zverse2.h 7 May 2004 17:02:32 -0000 1.2
@@ -5,8 +5,8 @@
* class VerseKey2
*/
-#ifndef ZVERSE_H
-#define ZVERSE_H
+#ifndef ZVERSE2_H
+#define ZVERSE2_H
#include <filemgr.h>
#include <fcntl.h>
Index: osisbook.h
===================================================================
RCS file: /cvs/core/sword/include/osisbook.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- osisbook.h 29 Apr 2004 15:59:54 -0000 1.5
+++ osisbook.h 7 May 2004 17:02:32 -0000 1.6
@@ -26,12 +26,10 @@
*/
#define TESTAMENT_HEADING 255
-#define OTBOOKS 39
-#define NTBOOKS 27
//#define NTOFFSET 24115 //24115 is offset to start of NT
+#if 0
#define OSISBMAX 68
-//#define MAXOSISBOOKS 93
-#define NOTINREFSYS -1
+#endif
[...1524 lines suppressed...]
-{32107, 11}, // Revelation of John:10
-{32119, 19}, // Revelation of John:11
-{32139, 17}, // Revelation of John:12
-{32157, 18}, // Revelation of John:13
-{32176, 20}, // Revelation of John:14
-{32197, 8}, // Revelation of John:15
-{32206, 21}, // Revelation of John:16
-{32228, 18}, // Revelation of John:17
-{32247, 24}, // Revelation of John:18
-{32272, 21}, // Revelation of John:19
-{32294, 15}, // Revelation of John:20
-{32310, 27}, // Revelation of John:21
-{32338, 21} // Revelation of John:22
-};
-
-int
- VerseKey2::offsize[2] =
- { NTBOOKS+OTBOOKS+3, sizeof (VerseKey2::kjvcps) / sizeof(bkref)
-};
More information about the sword-cvs
mailing list