Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qhashedstring.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant
4
5
#
include
"qhashedstring_p.h"
6
7
QT_BEGIN_NAMESPACE
8
9
QHashedStringRef QHashedStringRef::mid(
int
offset,
int
length)
const
10
{
11
Q_ASSERT(offset < m_length);
12
return
QHashedStringRef(m_data + offset,
13
(length == -1 || (offset + length) > m_length)?(m_length - offset):length);
14
}
15
16
QList<QHashedStringRef> QHashedStringRef::split(
const
QChar sep)
const
17
{
18
QList<QHashedStringRef> ret;
19
auto
curLength = 0;
20
auto
curOffset = m_data;
21
for
(
int
offset = 0; offset < m_length; ++offset) {
22
if
(*(m_data + offset) == sep) {
23
ret.push_back({curOffset, curLength});
24
curOffset = m_data + offset + 1;
25
curLength = 0;
26
}
else
{
27
++curLength;
28
}
29
}
30
if
(curLength > 0)
31
ret.push_back({curOffset, curLength});
32
return
ret;
33
}
34
35
bool
QHashedStringRef::endsWith(
const
QString &s)
const
36
{
37
QStringView view {m_data, m_length};
38
return
view.endsWith(s);
39
}
40
41
bool
QHashedStringRef::startsWith(
const
QString &s)
const
42
{
43
QStringView view {m_data, m_length};
44
return
view.startsWith(s);
45
}
46
47
int
QHashedStringRef::indexOf(
const
QChar &c,
int
from)
const
48
{
49
QStringView view {m_data, m_length};
50
return
view.indexOf(c, from);
51
}
52
53
QString QHashedStringRef::toString()
const
54
{
55
if
(m_length == 0)
56
return
QString();
57
return
QString(m_data, m_length);
58
}
59
60
QString
QHashedCStringRef
::toUtf16()
const
61
{
62
if
(m_length == 0)
63
return
QString();
64
65
QString rv;
66
rv.resize(m_length);
67
writeUtf16((quint16*)rv.data());
68
return
rv;
69
}
70
71
QT_END_NAMESPACE
QHashedCStringRef
Definition
qhashedstring_p.h:117
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtdeclarative
src
qml
qml
ftw
qhashedstring.cpp
Generated on
for Qt by
1.18.0