Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
4#include "qhashedstring_p.h"
5
7
9{
10 Q_ASSERT(offset < m_length);
11 return QHashedStringRef(m_data + offset,
12 (length == -1 || (offset + length) > m_length)?(m_length - offset):length);
13}
14
15QVector<QHashedStringRef> QHashedStringRef::split(const QChar sep) const
16{
17 QVector<QHashedStringRef> ret;
18 auto curLength = 0;
19 auto curOffset = m_data;
20 for (int offset = 0; offset < m_length; ++offset) {
21 if (*(m_data + offset) == sep) {
22 ret.push_back({curOffset, curLength});
23 curOffset = m_data + offset + 1;
24 curLength = 0;
25 } else {
26 ++curLength;
27 }
28 }
29 if (curLength > 0)
30 ret.push_back({curOffset, curLength});
31 return ret;
32}
33
35{
36 QStringView view {m_data, m_length};
37 return view.endsWith(s);
38}
39
41{
42 QStringView view {m_data, m_length};
43 return view.startsWith(s);
44}
45
46int QHashedStringRef::indexOf(const QChar &c, int from) const
47{
48 QStringView view {m_data, m_length};
49 return view.indexOf(c, from);
50}
51
53{
54 if (m_length == 0)
55 return QString();
56 return QString(m_data, m_length);
57}
58
60{
61 if (m_length == 0)
62 return QString();
63
64 QString rv;
65 rv.resize(m_length);
66 writeUtf16((quint16*)rv.data());
67 return rv;
68}
69
\inmodule QtCore
Q_AUTOTEST_EXPORT QString toUtf16() const
void writeUtf16(QChar *) const
bool startsWith(const QString &) const
int indexOf(const QChar &, int from=0) const
QString toString() const
QVector< QHashedStringRef > split(const QChar sep) const
QHashedStringRef mid(int, int) const
bool endsWith(const QString &) const
\inmodule QtCore
Definition qstringview.h:78
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
void resize(qsizetype size)
Sets the size of the string to size characters.
Definition qstring.cpp:2668
Combined button and popup list for selecting options.
return ret
GLenum GLuint GLenum GLsizei length
GLenum GLuint GLintptr offset
GLdouble s
[6]
Definition qopenglext.h:235
const GLubyte * c
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
static constexpr QChar sep
unsigned short quint16
Definition qtypes.h:48
QQuickView * view
[0]