Hex formatting support extended to 64 bits.

This commit is contained in:
Bart Trzynadlowski 2017-09-23 15:33:26 +00:00
parent 61a0517bd9
commit 98b0354dd6
2 changed files with 8 additions and 2 deletions

View file

@ -41,7 +41,7 @@ namespace Util
static const char hex_digits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
std::string Hex(uint32_t n, size_t num_digits)
std::string Hex(uint64_t n, size_t num_digits)
{
Util::Format f;
f << "0x";
@ -53,6 +53,11 @@ namespace Util
return f;
}
std::string Hex(uint64_t n)
{
return Hex(n, 16);
}
std::string Hex(uint32_t n)
{
return Hex(n, 8);

View file

@ -95,7 +95,8 @@ namespace Util
std::ostream &operator<<(std::ostream &os, const Format &format);
std::string ToLower(const std::string &str);
std::string TrimWhiteSpace(const std::string &str);
std::string Hex(uint32_t n, size_t num_digits);
std::string Hex(uint64_t n, size_t num_digits);
std::string Hex(uint64_t n);
std::string Hex(uint32_t n);
std::string Hex(uint16_t n);
std::string Hex(uint8_t n);