From a4f18c6d0db5b7a5da64e7a01cf7e10034b61c35 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Thu, 26 Jan 2023 17:24:05 +0200 Subject: [PATCH] QtMiscUtils: add isAsciiDigit helper This logic is used in various places in qtbase, put it in one place. Change-Id: I731b1ce0c7b38fd42a91799a0565aafa94d4e9d0 Reviewed-by: Thiago Macieira --- src/corelib/tools/qtools_p.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/corelib/tools/qtools_p.h b/src/corelib/tools/qtools_p.h index 2058f6349e7..b0fc13bbbab 100644 --- a/src/corelib/tools/qtools_p.h +++ b/src/corelib/tools/qtools_p.h @@ -49,6 +49,11 @@ constexpr inline int fromOct(uint c) noexcept return ((c >= '0') && (c <= '7')) ? int(c - '0') : -1; } +[[nodiscard]] constexpr inline bool isAsciiDigit(uchar c) noexcept +{ + return c >= '0' && c <= '9'; +} + constexpr inline char toAsciiLower(char ch) noexcept { return (ch >= 'A' && ch <= 'Z') ? ch - 'A' + 'a' : ch;