The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
versificationmgr.h
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * versificationmgr.h - class VersificationMgr: used for managing
4  * versification systems
5  *
6  * $Id: versificationmgr.h 3786 2020-08-30 11:35:14Z scribe $
7  *
8  * Copyright 2008-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 #include <list>
25 #include <defs.h>
26 #include <swcacher.h>
27 #include <swbuf.h>
28 
29 
30 #ifndef VERSIFICATIONMGR_H
31 #define VERSIFICATIONMGR_H
32 
33 
35 
36 typedef std::list <SWBuf>StringList;
37 
38 struct sbook;
39 class TreeKey;
40 
41 
42 struct abbrev {
43  const char *ab;
44  const char *osis;
45 };
46 
47 struct sbook {
50  const char *name;
51 
54  const char *osis;
55 
58  const char *prefAbbrev;
59 
62  unsigned char chapmax;
65  int *versemax;
66 };
67 
68 
70 
71 private:
73 
74  class Private;
75  Private *p;
76 
77  void init();
78 
79 protected:
81 
82 public:
83  class System;
84  class SWDLLEXPORT Book {
85  private:
86  friend class System;
87  friend struct BookOffsetLess;
88  class Private;
89  Private *p;
90 
93 
96 
99 
101  unsigned int chapMax;
102 
103  void init();
104 
105  public:
106  Book() { init(); }
107  Book(const Book &other);
108  Book &operator =(const Book &other);
109  Book(const char *longName, const char *osisName, const char *prefAbbrev, int chapMax) {
110  this->longName = longName;
111  this->osisName = osisName;
112  this->prefAbbrev = prefAbbrev;
113  this->chapMax = chapMax;
114  init();
115  }
116  ~Book();
117  const char *getLongName() const { return longName.c_str(); }
118  const char *getOSISName() const { return osisName.c_str(); }
119  const char *getPreferredAbbreviation() const { return prefAbbrev.c_str(); }
120  int getChapterMax() const { return chapMax; }
121  int getVerseMax(int chapter) const;
122  };
123 
125  private:
126  class Private;
127  Private *p;
129  int BMAX[2];
131  void init();
132  public:
133  System() { this->name = ""; init(); }
134  System(const System &other);
135  System &operator =(const System &other);
136  System(const char *name) { this->name = name; init(); }
137  ~System();
138  const char *getName() const { return name.c_str(); }
139  const Book *getBookByName(const char *bookName) const;
140  int getBookNumberByOSISName(const char *bookName) const;
141  const Book *getBook(int number) const;
142  int getBookCount() const;
143  void loadFromSBook(const sbook *ot, const sbook *nt, int *chMax, const unsigned char *mappings=NULL);
144  long getOffsetFromVerse(int book, int chapter, int verse) const;
145  char getVerseFromOffset(long offset, int *book, int *chapter, int *verse) const;
146  const int *getBMAX() const { return BMAX; };
147  long getNTStartOffset() const { return ntStartOffset; }
148  void translateVerse(const System *dstSys, const char **book, int *chapter, int *verse, int *verse_end) const;
149  };
150 
152  ~VersificationMgr();
153  static VersificationMgr *getSystemVersificationMgr();
154  static void setSystemVersificationMgr(VersificationMgr *newVersificationMgr);
155  const StringList getVersificationSystems() const;
156  const System *getVersificationSystem(const char *name) const;
157  void registerVersificationSystem(const char *name, const sbook *ot, const sbook *nt, int *chMax, const unsigned char *mappings=NULL);
158  void registerVersificationSystem(const char *name, const TreeKey *);
159 };
160 
161 SWDLLEXPORT extern const struct abbrev builtin_abbrevs[];
162 
164 #endif
#define SWORD_NAMESPACE_START
Definition: defs.h:39
SWORD_NAMESPACE_START struct abbrev builtin_abbrevs[]
Definition: canon_abbrevs.h:36
Definition: swbuf.h:47
#define SWDLLEXPORT
Definition: defs.h:171
System(const char *name)
const char * ab
const char * osis
void init()
Definition: installmgr.cpp:164
return NULL
Definition: regex.c:7953
std::list< SWBuf > StringList
Definition: swmodule.cpp:91
int * versemax
unsigned char chapmax
Book(const char *longName, const char *osisName, const char *prefAbbrev, int chapMax)
const char * getOSISName() const
const char * getPreferredAbbreviation() const
const char * getName() const
const char * name
const int * getBMAX() const
const char * prefAbbrev
static VersificationMgr * systemVersificationMgr
const char * getLongName() const
const char * osis
#define SWORD_NAMESPACE_END
Definition: defs.h:40