diff options
Diffstat (limited to 'src/corelib/tools/qtools_p.h')
-rw-r--r-- | src/corelib/tools/qtools_p.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/corelib/tools/qtools_p.h b/src/corelib/tools/qtools_p.h index 3876d3822c..53d5228c3b 100644 --- a/src/corelib/tools/qtools_p.h +++ b/src/corelib/tools/qtools_p.h @@ -46,9 +46,40 @@ // #include "QtCore/qglobal.h" +#include <limits> QT_BEGIN_NAMESPACE +namespace QtMiscUtils { +inline char toHexUpper(uint value) +{ + static const char hexdigits[] = "0123456789ABCDEF"; + return hexdigits[value & 0xF]; +} + +inline char toHexLower(uint value) +{ + static const char hexdigits[] = "0123456789abcdef"; + return hexdigits[value & 0xF]; +} + +inline int fromHex(uint c) +{ + if ((c >= '0') && (c <= '9')) + return c - '0'; + if ((c >= 'A') && (c <= 'F')) + return c - 'A' + 10; + if ((c >= 'a') && (c <= 'f')) + return c - 'a' + 10; + return -1; +} +} + +// We typically need an extra bit for qNextPowerOfTwo when determining the next allocation size. +enum { + MaxAllocSize = (1 << (std::numeric_limits<int>::digits - 1)) - 1 +}; + // implemented in qbytearray.cpp int Q_CORE_EXPORT qAllocMore(int alloc, int extra) Q_DECL_NOTHROW; |