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
21QT_BEGIN_NAMESPACE
22
23namespace QtParseCommon {
25{
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
44QT_END_NAMESPACE
45
46#endif // QPARSE_COMMON_P_H
constexpr operator bool() const noexcept
constexpr bool isEmpty() const
constexpr qsizetype size() const
constexpr QStringView used(QStringView text) const