From 98b0354dd6870dcdfc05ecbfd34f4a09932c9987 Mon Sep 17 00:00:00 2001 From: Bart Trzynadlowski Date: Sat, 23 Sep 2017 15:33:26 +0000 Subject: [PATCH] Hex formatting support extended to 64 bits. --- Src/Util/Format.cpp | 7 ++++++- Src/Util/Format.h | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Src/Util/Format.cpp b/Src/Util/Format.cpp index da16f74..df55349 100644 --- a/Src/Util/Format.cpp +++ b/Src/Util/Format.cpp @@ -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); diff --git a/Src/Util/Format.h b/Src/Util/Format.h index 91aa308..e434205 100644 --- a/Src/Util/Format.h +++ b/Src/Util/Format.h @@ -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);