diff options
Diffstat (limited to '')
-rw-r--r-- | lyt/common.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lyt/common.h b/lyt/common.h index 2cddffd..c75813b 100644 --- a/lyt/common.h +++ b/lyt/common.h @@ -49,6 +49,20 @@ inline quint32 BitExtract(quint32 value, int count, int start) { return (value & mask) >> (32 - (start + count)); } +inline quint32 BitInsert(quint32 value, int newValue, int count, int start) { + quint32 mask = 0; + for (int i = start; i < start+count; i++) { + mask |= (0x80000000 >> i); + } + + value &= ~mask; + value |= (newValue << (32 - (start + count))) & mask; + return value; +} + + + + QByteArray PadByteArray(QByteArray original, int newLength, char padWith='\0'); |