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 friend auto
53 operator<=>(CSwordTreeKey const & lhs, CSwordTreeKey const & rhs)
54 { return lhs.offset() <=> rhs.offset(); }
55
56 friend auto
57 operator==(CSwordTreeKey const & lhs, CSwordTreeKey const & rhs)
58 { return lhs.offset() == rhs.offset(); }
59
61
62 /**
63 \param k The Sword tree key which belongs to this key
64 \param module The module which belongs to this key
65 */
66 CSwordTreeKey(const sword::TreeKeyIdx *k,
68
69 CSwordTreeKey( const CSwordTreeKey& k );
70
71 sword::TreeKeyIdx const & asSwordKey() const noexcept final override;
72
73 void setModule(const CSwordModuleInfo *newModule) final override;
74
75 CSwordTreeKey* copy() const final override;
76
77 /**
78 * Returns the TreeKeyIdx::getLocalKey value in unicode.
79 * Local key is the last part of the tree key, for example "Subsection1" from "/Section1/Subsection1".
80 * Use this instead of getLocalKey() to avoid encoding problems.
81 */
82 QString getLocalNameUnicode();
83
84 QString key() const final override;
85
86 bool setKey(const QString &key) final override;
87
88 bool setKey(const char *key) final override;
89
90 bool hasChildren() { return m_key.hasChildren(); }
91 void positionToRoot() { m_key.root(); }
92 bool positionToParent() { return m_key.parent(); }
93 bool positionToFirstChild() { return m_key.firstChild(); }
94 bool positionToNextSibling() { return m_key.nextSibling(); }
95 Offset offset() const { return m_key.getOffset(); }
96 void setOffset(Offset value) { m_key.setOffset(value); }
97
98 protected:
99
100 const char * rawKey() const final override;
101
102 private: // fields:
103
104 sword::TreeKeyIdx m_key;
105
106};
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)