BibleTime
cswordtreekey.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-2026 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 "cswordkey.h"
16
17#include <QString>
18#include <utility>
19
20// Sword includes:
21#pragma GCC diagnostic push
22#pragma GCC diagnostic ignored "-Wextra-semi"
23#pragma GCC diagnostic ignored "-Wsuggest-override"
24#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
25#ifdef __clang__
26#pragma clang diagnostic push
27#pragma clang diagnostic ignored "-Wsuggest-destructor-override"
28#endif
29#include <treekeyidx.h>
30#ifdef __clang__
31#pragma clang diagnostic pop
32#endif
33#pragma GCC diagnostic pop
34
35
37
38/** BibleTime's implementation of Sword's TreeKeyIdx class.
39 * @short CSwordKey implementation for Sword's TreeKey
40 * @author The BibleTime team
41 */
42
43class CSwordTreeKey final : public CSwordKey {
44
45 public: // types:
46
47 using Offset =
48 decltype(std::declval<sword::TreeKeyIdx const &>().getOffset());
49
50 public:
51
52 #define BibleTime_CSwordTreeKey_DEFINE_COMP(op) \
53 friend auto operator op(CSwordTreeKey const & lhs, \
54 CSwordTreeKey const & rhs) \
55 { return lhs.offset() op rhs.offset(); }
56 #if __cpp_impl_three_way_comparison >= 201907L
59 #else
66 #endif
67 #undef BibleTime_CSwordTreeKey_DEFINE_COMP
68
69 CSwordTreeKey & operator=(CSwordTreeKey const &) = delete;
70
71 /**
72 \param k The Sword tree key which belongs to this key
73 \param module The module which belongs to this key
74 */
75 CSwordTreeKey(const sword::TreeKeyIdx *k,
77
78 CSwordTreeKey( const CSwordTreeKey& k );
79
80 sword::TreeKeyIdx const & asSwordKey() const noexcept final override;
81
82 void setModule(const CSwordModuleInfo *newModule) final override;
83
84 CSwordTreeKey* copy() const final override;
85
86 /**
87 * Returns the TreeKeyIdx::getLocalKey value in unicode.
88 * Local key is the last part of the tree key, for example "Subsection1" from "/Section1/Subsection1".
89 * Use this instead of getLocalKey() to avoid encoding problems.
90 */
91 QString getLocalNameUnicode();
92
93 QString key() const final override;
94
95 bool setKey(const QString &key) final override;
96
97 bool setKey(const char *key) final override;
98
99 bool hasChildren() { return m_key.hasChildren(); }
100 void positionToRoot() { m_key.root(); }
101 bool positionToParent() { return m_key.parent(); }
102 bool positionToFirstChild() { return m_key.firstChild(); }
103 bool positionToNextSibling() { return m_key.nextSibling(); }
104 Offset offset() const { return m_key.getOffset(); }
105 void setOffset(Offset value) { m_key.setOffset(value); }
106
107 protected:
108
109 const char * rawKey() const final override;
110
111 private: // fields:
112
113 sword::TreeKeyIdx m_key;
114
115};
CSwordModuleInfo const * module() const
Definition cswordkey.h:68
CSwordKey & operator=(CSwordKey const &)=delete
CSwordKey implementation for Sword's TreeKey.
void positionToRoot()
bool positionToFirstChild()
bool positionToNextSibling()
const char * rawKey() const final override
bool positionToParent()
QString getLocalNameUnicode()
QString key() const final override
Offset offset() const
bool setKey(const QString &key) final override
void setModule(const CSwordModuleInfo *newModule) final override
decltype(std::declval< sword::TreeKeyIdx const & >().getOffset()) Offset
sword::TreeKeyIdx const & asSwordKey() const noexcept final override
void setOffset(Offset value)
BibleTime_CSwordTreeKey_DEFINE_COMP(<) BibleTime_CSwordTreeKey_DEFINE_COMP(<
sword::TreeKeyIdx m_key
CSwordTreeKey * copy() const final override