From 575029f09bedc6678bc6636361c82aabc9df7765 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 23 Jan 2015 21:22:16 +0100 Subject: QtMiscUtils: add to/fromOct ...mirroring to/fromHex. Change-Id: Ie06bd3cc636b0afbc97606eadb8980079a7677a3 Reviewed-by: Thiago Macieira --- src/corelib/tools/qtools_p.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/corelib/tools/qtools_p.h') diff --git a/src/corelib/tools/qtools_p.h b/src/corelib/tools/qtools_p.h index 320423d703..9efd964205 100644 --- a/src/corelib/tools/qtools_p.h +++ b/src/corelib/tools/qtools_p.h @@ -70,6 +70,16 @@ Q_DECL_CONSTEXPR inline int fromHex(uint c) Q_DECL_NOTHROW ((c >= 'a') && (c <= 'f')) ? c - 'a' + 10 : /* otherwise */ -1; } + +Q_DECL_CONSTEXPR inline char toOct(uint value) Q_DECL_NOTHROW +{ + return '0' + char(value & 0x7); +} + +Q_DECL_CONSTEXPR inline int fromOct(uint c) Q_DECL_NOTHROW +{ + return ((c >= '0') && (c <= '7')) ? c - '0' : -1; +} } // We typically need an extra bit for qNextPowerOfTwo when determining the next allocation size. -- cgit v1.2.3