Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
codechunk.h
Go to the documentation of this file.
1// Copyright (C) 2019 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef CODECHUNK_H
5#define CODECHUNK_H
6
7#include <QtCore/qstring.h>
8
9QT_BEGIN_NAMESPACE
10
11// ### get rid of that class
12
13class CodeChunk
14{
15public:
16 CodeChunk() : m_hotspot(-1) { }
17
18 void append(const QString &lexeme);
19 void appendHotspot()
20 {
21 if (m_hotspot == -1)
22 m_hotspot = m_str.size();
23 }
24
25 [[nodiscard]] bool isEmpty() const { return m_str.isEmpty(); }
26 void clear() { m_str.clear(); }
27 [[nodiscard]] QString toString() const { return m_str; }
28 [[nodiscard]] QString left() const
29 {
30 return m_str.left(m_hotspot == -1 ? m_str.size() : m_hotspot);
31 }
32 [[nodiscard]] QString right() const
33 {
34 return m_str.mid(m_hotspot == -1 ? m_str.size() : m_hotspot);
35 }
36
37private:
38 QString m_str {};
39 qsizetype m_hotspot {};
40};
41
42inline bool operator==(const CodeChunk &c, const CodeChunk &d)
43{
44 return c.toString() == d.toString();
45}
46
47inline bool operator!=(const CodeChunk &c, const CodeChunk &d)
48{
49 return !(c == d);
50}
51
52inline bool operator<(const CodeChunk &c, const CodeChunk &d)
53{
54 return c.toString() < d.toString();
55}
56
57inline bool operator>(const CodeChunk &c, const CodeChunk &d)
58{
59 return d < c;
60}
61
62inline bool operator<=(const CodeChunk &c, const CodeChunk &d)
63{
64 return !(c > d);
65}
66
67inline bool operator>=(const CodeChunk &c, const CodeChunk &d)
68{
69 return !(c < d);
70}
71
72QT_END_NAMESPACE
73
74#endif
static const bool needSpace[9][9]
Definition codechunk.cpp:40
@ RAngle
Definition codechunk.cpp:8
@ Paren
Definition codechunk.cpp:8
@ Comma
Definition codechunk.cpp:8
@ RBrace
Definition codechunk.cpp:8
@ Other
Definition codechunk.cpp:8
@ Alnum
Definition codechunk.cpp:8
@ Gizmo
Definition codechunk.cpp:8
@ LBrace
Definition codechunk.cpp:8
@ Colon
Definition codechunk.cpp:8
static int category(QChar ch)
Definition codechunk.cpp:53
static const int charCategory[256]
Definition codechunk.cpp:11
bool operator>(const CodeChunk &c, const CodeChunk &d)
Definition codechunk.h:57
bool operator<=(const CodeChunk &c, const CodeChunk &d)
Definition codechunk.h:62
bool operator>=(const CodeChunk &c, const CodeChunk &d)
Definition codechunk.h:67
bool operator<(const CodeChunk &c, const CodeChunk &d)
Definition codechunk.h:52
bool operator==(const CodeChunk &c, const CodeChunk &d)
Definition codechunk.h:42
bool operator!=(const CodeChunk &c, const CodeChunk &d)
Definition codechunk.h:47
Combined button and popup list for selecting options.