This commit is contained in:
Igor Pavlov
2017-04-30 00:00:00 +00:00
committed by Kornel
parent 603abd5528
commit 2efa10565a
442 changed files with 15479 additions and 8525 deletions

View File

@@ -2,6 +2,8 @@
#include "StdAfx.h"
#include "../../C/CpuArch.h"
#include "IntToString.h"
#define CONVERT_INT_TO_STR(charType, tempSize) \
@@ -46,6 +48,12 @@ void ConvertUInt64ToOct(UInt64 val, char *s) throw()
while (i);
}
#define GET_HEX_CHAR(t) ((char)(((t < 10) ? ('0' + t) : ('A' + (t - 10)))))
static inline char GetHexChar(unsigned t) { return GET_HEX_CHAR(t); }
void ConvertUInt32ToHex(UInt32 val, char *s) throw()
{
UInt32 v = val;
@@ -59,13 +67,14 @@ void ConvertUInt32ToHex(UInt32 val, char *s) throw()
s[i] = 0;
do
{
unsigned t = (unsigned)((val & 0xF));
unsigned t = (unsigned)(val & 0xF);
val >>= 4;
s[--i] = (char)((t < 10) ? ('0' + t) : ('A' + (t - 10)));
s[--i] = GET_HEX_CHAR(t);
}
while (i);
}
void ConvertUInt64ToHex(UInt64 val, char *s) throw()
{
UInt64 v = val;
@@ -79,9 +88,9 @@ void ConvertUInt64ToHex(UInt64 val, char *s) throw()
s[i] = 0;
do
{
unsigned t = (unsigned)((val & 0xF));
unsigned t = (unsigned)(val & 0xF);
val >>= 4;
s[--i] = (char)((t < 10) ? ('0' + t) : ('A' + (t - 10)));
s[--i] = GET_HEX_CHAR(t);
}
while (i);
}
@@ -93,7 +102,7 @@ void ConvertUInt32ToHex8Digits(UInt32 val, char *s) throw()
{
unsigned t = val & 0xF;
val >>= 4;
s[i] = (char)(((t < 10) ? ('0' + t) : ('A' + (t - 10))));
s[i] = GET_HEX_CHAR(t);;
}
}
@@ -144,3 +153,41 @@ void ConvertInt64ToString(Int64 val, wchar_t *s) throw()
}
ConvertUInt64ToString(val, s);
}
static void ConvertByteToHex2Digits(unsigned v, char *s) throw()
{
s[0] = GetHexChar(v >> 4);
s[1] = GetHexChar(v & 0xF);
}
static void ConvertUInt16ToHex4Digits(UInt32 val, char *s) throw()
{
ConvertByteToHex2Digits(val >> 8, s);
ConvertByteToHex2Digits(val & 0xFF, s + 2);
}
char *RawLeGuidToString(const Byte *g, char *s) throw()
{
ConvertUInt32ToHex8Digits(GetUi32(g ), s); s += 8; *s++ = '-';
ConvertUInt16ToHex4Digits(GetUi16(g + 4), s); s += 4; *s++ = '-';
ConvertUInt16ToHex4Digits(GetUi16(g + 6), s); s += 4; *s++ = '-';
for (unsigned i = 0; i < 8; i++)
{
if (i == 2)
*s++ = '-';
ConvertByteToHex2Digits(g[8 + i], s);
s += 2;
}
*s = 0;
return s;
}
char *RawLeGuidToString_Braced(const Byte *g, char *s) throw()
{
*s++ = '{';
s = RawLeGuidToString(g, s);
*s++ = '}';
*s = 0;
return s;
}