diff options
| author | Tatiana Borisova <tatiana.borisova@qt.io> | 2024-07-11 12:20:26 +0200 |
|---|---|---|
| committer | Marc Mutz <marc.mutz@qt.io> | 2024-08-01 11:04:23 +0000 |
| commit | 2aa39be4c23ad837c6a09b5cf74c74da670d7ebf (patch) | |
| tree | 84aeb31ac26249e8011f3644f556a0769a4d9af5 /src/corelib/io/qdebug.cpp | |
| parent | 1442a9ea479d197ed338f440d5106a7e195c4ee2 (diff) | |
Add QDebug printing for the std/Qt::<name>_ordering types
[ChangeLog][QtCore][QDebug] Added possibility to print {std/Qt}
weak/partial/strong_ordering values with QDebug << operator.
Change-Id: Ie880cb34c19f79a404c692c2322b3460d72bfde4
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/corelib/io/qdebug.cpp')
| -rw-r--r-- | src/corelib/io/qdebug.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp index 9a00b0b2006..cd835f548c0 100644 --- a/src/corelib/io/qdebug.cpp +++ b/src/corelib/io/qdebug.cpp @@ -511,6 +511,46 @@ void QDebug::putUInt128([[maybe_unused]] const void *p) stream->ts << int128Warning(); } +/*! + \since 6.9 + \internal + Helper to the <Std/Qt>::<>_ordering debug output. + It generates the string in following format: + <Qt/Std>::<weak/partial/strong>_ordering::<less/equal/greater/unordered> + */ +void QDebug::putQtOrdering(QtOrderingPrivate::QtOrderingTypeFlag flags, Qt::partial_ordering order) +{ + using QtOrderingPrivate::QtOrderingType; + std::string result; + if ((flags & QtOrderingType::StdOrder) == QtOrderingType::StdOrder) + result += "std"; + else if ((flags & QtOrderingType::QtOrder) == QtOrderingType::QtOrder) + result += "Qt"; + + result += "::"; + const bool isStrong = ((flags & QtOrderingType::Strong) == QtOrderingType::Strong); + if (isStrong) + result += "strong"; + else if ((flags & QtOrderingType::Weak) == QtOrderingType::Weak) + result += "weak"; + else if ((flags & QtOrderingType::Partial) == QtOrderingType::Partial) + result += "partial"; + result += "_ordering::"; + + if (order == Qt::partial_ordering::equivalent) { + if (isStrong) + result += "equal"; + else + result += "equivalent"; + } else if (order == Qt::partial_ordering::greater) { + result += "greater"; + } else if (order == Qt::partial_ordering::less) { + result += "less"; + } else { + result += "unordered"; + } + stream->ts << result.data(); +} /*! \fn QDebug::swap(QDebug &other) @@ -949,6 +989,15 @@ QDebug &QDebug::resetFormat() */ /*! + \fn template <typename T, QDebug::if_ordering_type<T>> QDebug::operator<<(QDebug debug, T t) + \since 6.9 + Prints the Qt or std ordering value \a t to the \a debug object. + + \note This function only participates in overload resolution if \c T + is one of <Qt/Std>::<weak/partial/strong>_ordering. +*/ + +/*! \since 6.5 \fn template <typename Char, typename...Args> QDebug &QDebug::operator<<(const std::basic_string<Char, Args...> &s) \fn template <typename Char, typename...Args> QDebug &QDebug::operator<<(std::basic_string_view<Char, Args...> s) |
