BibleTime
cswordbiblemoduleinfo.h
Go to the documentation of this file.
1 /*********
2 *
3 * In the name of the Father, and of the Son, and of the Holy Spirit.
4 *
5 * This file is part of BibleTime's source code, https://bibletime.info/
6 *
7 * Copyright 1999-2021 by the BibleTime developers.
8 * The BibleTime source code is licensed under the GNU General Public License
9 * version 2.0.
10 *
11 **********/
12 
13 #pragma once
14 
15 #include "cswordmoduleinfo.h"
16 
17 #include <optional>
18 #include <QStringList>
19 #include "../keys/cswordversekey.h"
20 
21 
22 /**
23  \brief Implementation for Sword Bibles.
24 
25  This is the CModuleInfo imlementation for Bible modules managed by Sword.
26 */
28  Q_OBJECT
29 
30  public: // methods:
31  CSwordBibleModuleInfo(sword::SWModule & module,
34 
35  ~CSwordBibleModuleInfo() noexcept override;
36 
37  /**
38  \returns the number of avalable verses for the given chapter and book.
39  \param book The number book we should use
40  \param chapter The chapter we should use
41  */
42  unsigned int verseCount(const unsigned int book,
43  const unsigned int chapter) const;
44 
45  /**
46  \returns the number of avalable verses for the given chapter and book.
47  \param book The name of the book we use
48  \param chapter The number of the chapter we use
49  */
50  unsigned int verseCount(const QString &book,
51  const unsigned int chapter) const;
52 
53  /**
54  \returns the number of available chapters in the given book.
55  */
56  unsigned int chapterCount(const unsigned int book) const;
57 
58  /**
59  \returns the number of available chapters in the given book.
60  */
61  unsigned int chapterCount(const QString &book) const;
62 
63  /**
64  \returns a QStringList containing the books available in this module.
65  */
66  QStringList const & books() const;
67 
68  /**
69  \returns the index of the book given by its name.
70  \retval 0 if a book with the given name was not found.
71  */
72  unsigned int bookNumber(const QString &book) const;
73 
74  /**
75  \returns whether this module has the Old Testament texts.
76  */
77  bool hasOldTestament() const {
79  initBounds();
80  return m_hasOT;
81  }
82 
83  /**
84  \returns whether this module has the New Testament texts.
85  */
86  bool hasNewTestament() const {
88  initBounds();
89  return m_hasNT;
90  }
91 
92  /**
93  \returns the key which represents the lower bound of this module.
94  */
95  CSwordVerseKey const & lowerBound() const {
97  initBounds();
98  return m_lowerBound;
99  }
100 
101  /**
102  \returns the key which represents the upper bound of this module.
103  */
104  CSwordVerseKey const & upperBound() const {
105  if (!m_boundsInitialized)
106  initBounds();
107  return m_upperBound;
108  }
109 
110  CSwordKey * createKey() const final override;
111 
112  private: // methods:
113 
114  void initBounds() const;
115 
116  private: // fields:
117 
118  mutable bool m_boundsInitialized;
121  mutable bool m_hasOT;
122  mutable bool m_hasNT;
123 
124  mutable std::optional<QStringList> m_bookList; //This booklist is cached
125  mutable QString m_cachedLocale;
126 };
The backend layer main class, a backend implementation of Sword.
Definition: cswordbackend.h:56
Implementation for Sword Bibles.
unsigned int verseCount(const unsigned int book, const unsigned int chapter) const
CSwordVerseKey const & lowerBound() const
unsigned int chapterCount(const unsigned int book) const
~CSwordBibleModuleInfo() noexcept override
CSwordBibleModuleInfo(sword::SWModule &module, CSwordBackend &backend, ModuleType type=Bible)
QStringList const & books() const
std::optional< QStringList > m_bookList
unsigned int bookNumber(const QString &book) const
CSwordKey * createKey() const final override
CSwordVerseKey const & upperBound() const
CSwordBackend & backend() const
ModuleType type() const
CSwordKey implementation for Sword's VerseKey.