summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qtools_p.h
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-01-23 21:22:16 +0100
committerMarc Mutz <marc.mutz@kdab.com>2015-02-12 09:57:51 +0000
commit575029f09bedc6678bc6636361c82aabc9df7765 (patch)
tree2bee0385e8a96ffb436fcc5605c99aa706fabf17 /src/corelib/tools/qtools_p.h
parent26d94c1ca783782dde134cd6042303a7c4804812 (diff)
QtMiscUtils: add to/fromOct
...mirroring to/fromHex. Change-Id: Ie06bd3cc636b0afbc97606eadb8980079a7677a3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qtools_p.h')
-rw-r--r--src/corelib/tools/qtools_p.h10
1 files changed, 10 insertions, 0 deletions
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.