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
qqmlsourcecoordinate_p.h
Go to the documentation of this file.
1// Copyright (C) 2018 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#ifndef QQMLSOURCECOORDINATE_P_H
6#define QQMLSOURCECOORDINATE_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtCore/private/qglobal_p.h>
20
21#include <limits>
22
23QT_BEGIN_NAMESPACE
24
25// These methods are needed because in some public methods we historically interpret -1 as the
26// invalid line or column, even though all the lines and columns are 1-based. Also, the different
27// integer ranges may turn certain large values into invalid ones on conversion.
28
29template<typename From, typename To>
30To qmlConvertSourceCoordinate(From n);
31
32template<>
33inline quint16 qmlConvertSourceCoordinate<int, quint16>(int n)
34{
35 return (n > 0 && n <= int(std::numeric_limits<quint16>::max())) ? quint16(n) : 0;
36}
37
38template<>
39inline quint32 qmlConvertSourceCoordinate<int, quint32>(int n)
40{
41 return n > 0 ? quint32(n) : 0u;
42}
43
44// TODO: In Qt6, change behavior and make the invalid coordinate 0 for the following two methods.
45
46template<>
47inline int qmlConvertSourceCoordinate<quint16, int>(quint16 n)
48{
49 return (n == 0u) ? -1 : int(n);
50}
51
52template<>
53inline int qmlConvertSourceCoordinate<quint32, int>(quint32 n)
54{
55 return (n == 0u || n > quint32(std::numeric_limits<int>::max())) ? -1 : int(n);
56}
57
59
60#endif // QQMLSOURCECOORDINATE_P_H
QList< QQmlError > errors
Definition qqmlinfo.cpp:159
QQmlInfoPrivate(QtMsgType type)
Definition qqmlinfo.cpp:149
const QObject * object
Definition qqmlinfo.cpp:157
QtMsgType msgType
Definition qqmlinfo.cpp:156
\inmodule QtQml
\inmodule QtCore
Definition qmutex.h:342
Combined button and popup list for selecting options.
Definition qjsvalue.h:24
Q_DECLARE_TYPEINFO(QByteArrayView, Q_PRIMITIVE_TYPE)
#define MESSAGE_FUNCS(FuncName, MessageLevel)
Definition qqmlinfo.cpp:224
const QMetaObject * dynamicQmlListMarker(const QtPrivate::QMetaTypeInterface *)
const QMetaObject * dynamicQmlMetaObject(const QtPrivate::QMetaTypeInterface *iface)
const QtPrivate::QMetaTypeInterface * valueType