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
qtparsecommon_p.h
Go to the documentation of this file.
1
// Copyright (C) 2026 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
#
ifndef
QPARSE_COMMON_P_H
4
#
define
QPARSE_COMMON_P_H
5
6
//
7
// W A R N I N G
8
// -------------
9
//
10
// This file is not part of the Qt API. It exists purely as an
11
// implementation detail. This header file may change from version to
12
// version without notice, or even be removed.
13
//
14
// We mean it.
15
//
16
17
#
include
<
QtCore
/
private
/
qglobal_p
.
h
>
18
#
include
<
QtCore
/
qassert
.
h
>
19
#
include
<
QtCore
/
qstringview
.
h
>
20
21
QT_BEGIN_NAMESPACE
22
23
namespace
QtParseCommon
{
24
struct
ParsedText
25
{
26
qsizetype
startIndex
= 0;
27
qsizetype
endIndex
= 0;
28
29
constexpr
operator
bool
()
const
noexcept
{
return
endIndex > startIndex; }
30
constexpr
bool
isEmpty
()
const
{
return
endIndex <= startIndex; }
31
// size() is a UTF-16 length, not a count of Unicode characters:
32
constexpr
qsizetype
size
()
const
{
return
endIndex - startIndex; }
33
// text must be the same as was passed to whatever's parsing produced this:
34
constexpr
QStringView
used
(QStringView text)
const
35
{
36
Q_PRE(0 <= startIndex);
37
Q_PRE(startIndex <= endIndex);
38
Q_PRE(endIndex <= text.size());
39
return
text.first(endIndex).sliced(startIndex);
40
}
41
};
42
}
43
44
QT_END_NAMESPACE
45
46
#
endif
// QPARSE_COMMON_P_H
QtParseCommon
Definition
qtparsecommon_p.h:23
QtParseCommon::ParsedText
Definition
qtparsecommon_p.h:25
QtParseCommon::ParsedText::operator bool
constexpr operator bool() const noexcept
Definition
qtparsecommon_p.h:29
QtParseCommon::ParsedText::endIndex
qsizetype endIndex
Definition
qtparsecommon_p.h:27
QtParseCommon::ParsedText::isEmpty
constexpr bool isEmpty() const
Definition
qtparsecommon_p.h:30
QtParseCommon::ParsedText::size
constexpr qsizetype size() const
Definition
qtparsecommon_p.h:32
QtParseCommon::ParsedText::used
constexpr QStringView used(QStringView text) const
Definition
qtparsecommon_p.h:34
QtParseCommon::ParsedText::startIndex
qsizetype startIndex
Definition
qtparsecommon_p.h:26
qtbase
src
corelib
parse
qtparsecommon_p.h
Generated on
for Qt by
1.16.1