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