summaryrefslogtreecommitdiffstats
path: root/src/corelib/time/qcalendar.h
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2021-06-22 12:29:23 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2021-07-19 11:32:15 +0200
commit1c547698ac3ff25e7581f033886318ee98eacc0a (patch)
tree0264566d82c912f7f393fc515388638addfa8284 /src/corelib/time/qcalendar.h
parentd115f17cb84f759c2146eaaa25bf52a9d7b900f0 (diff)
Make QCalendarBackend's ID an opaque type
As Giuseppe pointed out in API change review, an opaque type should be used. Task-number: QTBUG-94407 Pick-to: 6.2 Change-Id: I862a6f52d284317e1243fd91f45bb0af130d154a Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'src/corelib/time/qcalendar.h')
-rw-r--r--src/corelib/time/qcalendar.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/corelib/time/qcalendar.h b/src/corelib/time/qcalendar.h
index e6907f6a17..c3d8800db8 100644
--- a/src/corelib/time/qcalendar.h
+++ b/src/corelib/time/qcalendar.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -130,12 +130,24 @@ public:
// New entries must be added to the \enum doc in qcalendar.cpp and
// handled in QCalendarBackend::fromEnum()
Q_ENUM(System)
+ class SystemId
+ {
+ const size_t id;
+ friend class QCalendarBackend;
+ constexpr bool isInEnum() const { return id <= size_t(QCalendar::System::Last); }
+ constexpr SystemId(QCalendar::System e) : id(size_t(e)) {}
+ constexpr SystemId(size_t i) : id(i) {}
+ public:
+ constexpr SystemId() : id(~size_t(0)) {}
+ constexpr size_t index() const noexcept { return id; }
+ constexpr bool isValid() const noexcept { return ~id; }
+ };
explicit QCalendar(); // Gregorian, optimised
explicit QCalendar(System system);
explicit QCalendar(QLatin1String name);
explicit QCalendar(QStringView name);
- explicit QCalendar(size_t id);
+ explicit QCalendar(SystemId id);
// QCalendar is a trivially copyable value type.
bool isValid() const { return d != nullptr; }