formatHex with lower case (#3657)

This commit is contained in:
JackyWoo
2022-07-05 03:25:02 +08:00
committed by GitHub
parent 3e4a286c9d
commit b1823b61c0
4 changed files with 107 additions and 56 deletions

View File

@@ -59,13 +59,13 @@ public:
/// right justified and zero-padded in a field
/// having at least the specified width.
static std::string formatHex(int value, bool prefix = false);
static std::string formatHex(int value, bool prefix = false, bool upper = true);
/// Formats an int value in hexadecimal notation.
/// If prefix is true, "0x" prefix is prepended to the
/// resulting string.
/// The value is treated as unsigned.
static std::string formatHex(int value, int width, bool prefix = false);
static std::string formatHex(int value, int width, bool prefix = false, bool upper = true);
/// Formats a int value in hexadecimal notation,
/// right justified and zero-padded in
/// a field having at least the specified width.
@@ -86,12 +86,12 @@ public:
/// right justified and zero-padded in a field having at
/// least the specified width.
static std::string formatHex(unsigned value, bool prefix = false);
static std::string formatHex(unsigned value, bool prefix = false, bool upper = true);
/// Formats an unsigned int value in hexadecimal notation.
/// If prefix is true, "0x" prefix is prepended to the
/// resulting string.
static std::string formatHex(unsigned value, int width, bool prefix = false);
static std::string formatHex(unsigned value, int width, bool prefix = false, bool upper = true);
/// Formats a int value in hexadecimal notation,
/// right justified and zero-padded in
/// a field having at least the specified width.
@@ -111,13 +111,13 @@ public:
/// right justified and zero-padded in a field
/// having at least the specified width.
static std::string formatHex(long value, bool prefix = false);
static std::string formatHex(long value, bool prefix = false, bool upper = true);
/// Formats an unsigned long value in hexadecimal notation.
/// If prefix is true, "0x" prefix is prepended to the
/// resulting string.
/// The value is treated as unsigned.
static std::string formatHex(long value, int width, bool prefix = false);
static std::string formatHex(long value, int width, bool prefix = false, bool upper = true);
/// Formats an unsigned long value in hexadecimal notation,
/// right justified and zero-padded in a field having at least the
/// specified width.
@@ -138,12 +138,12 @@ public:
/// right justified and zero-padded
/// in a field having at least the specified width.
static std::string formatHex(unsigned long value, bool prefix = false);
static std::string formatHex(unsigned long value, bool prefix = false, bool upper = true);
/// Formats an unsigned long value in hexadecimal notation.
/// If prefix is true, "0x" prefix is prepended to the
/// resulting string.
static std::string formatHex(unsigned long value, int width, bool prefix = false);
static std::string formatHex(unsigned long value, int width, bool prefix = false, bool upper = true);
/// Formats an unsigned long value in hexadecimal notation,
/// right justified and zero-padded in a field having at least the
/// specified width.
@@ -165,13 +165,13 @@ public:
/// right justified and zero-padded in a field having at least
/// the specified width.
static std::string formatHex(long long value, bool prefix = false);
static std::string formatHex(long long value, bool prefix = false, bool upper = true);
/// Formats a 64-bit integer value in hexadecimal notation.
/// If prefix is true, "0x" prefix is prepended to the
/// resulting string.
/// The value is treated as unsigned.
static std::string formatHex(long long value, int width, bool prefix = false);
static std::string formatHex(long long value, int width, bool prefix = false, bool upper = true);
/// Formats a 64-bit integer value in hexadecimal notation,
/// right justified and zero-padded in a field having at least
/// the specified width.
@@ -190,12 +190,12 @@ public:
/// right justified and zero-padded in a field having at least the
/// specified width.
static std::string formatHex(unsigned long long value, bool prefix = false);
static std::string formatHex(unsigned long long value, bool prefix = false, bool upper = true);
/// Formats a 64-bit integer value in hexadecimal notation.
/// If prefix is true, "0x" prefix is prepended to the
/// resulting string.
static std::string formatHex(unsigned long long value, int width, bool prefix = false);
static std::string formatHex(unsigned long long value, int width, bool prefix = false, bool upper = true);
/// Formats a 64-bit integer value in hexadecimal notation,
/// right justified and zero-padded in a field having at least
/// the specified width. If prefix is true, "0x" prefix is
@@ -215,13 +215,13 @@ public:
/// right justified and zero-padded in a field having at least
/// the specified width.
static std::string formatHex(Int64 value, bool prefix = false);
static std::string formatHex(Int64 value, bool prefix = false, bool upper = true);
/// Formats a 64-bit integer value in hexadecimal notation.
/// If prefix is true, "0x" prefix is prepended to the
/// resulting string.
/// The value is treated as unsigned.
static std::string formatHex(Int64 value, int width, bool prefix = false);
static std::string formatHex(Int64 value, int width, bool prefix = false, bool upper = true);
/// Formats a 64-bit integer value in hexadecimal notation,
/// right justified and zero-padded in a field having at least
/// the specified width.
@@ -240,12 +240,12 @@ public:
/// right justified and zero-padded in a field having at least the
/// specified width.
static std::string formatHex(UInt64 value, bool prefix = false);
static std::string formatHex(UInt64 value, bool prefix = false, bool upper = true);
/// Formats a 64-bit integer value in hexadecimal notation.
/// If prefix is true, "0x" prefix is prepended to the
/// resulting string.
static std::string formatHex(UInt64 value, int width, bool prefix = false);
static std::string formatHex(UInt64 value, int width, bool prefix = false, bool upper = true);
/// Formats a 64-bit integer value in hexadecimal notation,
/// right justified and zero-padded in a field having at least
/// the specified width. If prefix is true, "0x" prefix is
@@ -532,18 +532,18 @@ inline std::string NumberFormatter::format0(int value, int width)
}
inline std::string NumberFormatter::formatHex(int value, bool prefix)
inline std::string NumberFormatter::formatHex(int value, bool prefix, bool upper)
{
std::string result;
uIntToStr(static_cast<unsigned int>(value), 0x10, result, prefix);
uIntToStr(static_cast<unsigned int>(value), 0x10, result, prefix, -1, ' ', 0, upper);
return result;
}
inline std::string NumberFormatter::formatHex(int value, int width, bool prefix)
inline std::string NumberFormatter::formatHex(int value, int width, bool prefix, bool upper)
{
std::string result;
uIntToStr(static_cast<unsigned int>(value), 0x10, result, prefix, width, '0');
uIntToStr(static_cast<unsigned int>(value), 0x10, result, prefix, width, '0', 0, upper);
return result;
}
@@ -572,18 +572,18 @@ inline std::string NumberFormatter::format0(unsigned int value, int width)
}
inline std::string NumberFormatter::formatHex(unsigned value, bool prefix)
inline std::string NumberFormatter::formatHex(unsigned value, bool prefix, bool upper)
{
std::string result;
uIntToStr(value, 0x10, result, prefix);
uIntToStr(value, 0x10, result, prefix, -1, ' ', 0, upper);
return result;
}
inline std::string NumberFormatter::formatHex(unsigned value, int width, bool prefix)
inline std::string NumberFormatter::formatHex(unsigned value, int width, bool prefix, bool upper)
{
std::string result;
uIntToStr(value, 0x10, result, prefix, width, '0');
uIntToStr(value, 0x10, result, prefix, width, '0', 0, upper);
return result;
}
@@ -612,18 +612,18 @@ inline std::string NumberFormatter::format0(long value, int width)
}
inline std::string NumberFormatter::formatHex(long value, bool prefix)
inline std::string NumberFormatter::formatHex(long value, bool prefix, bool upper)
{
std::string result;
uIntToStr(static_cast<unsigned long>(value), 0x10, result, prefix);
uIntToStr(static_cast<unsigned long>(value), 0x10, result, prefix, -1, ' ', 0, upper);
return result;
}
inline std::string NumberFormatter::formatHex(long value, int width, bool prefix)
inline std::string NumberFormatter::formatHex(long value, int width, bool prefix, bool upper)
{
std::string result;
uIntToStr(static_cast<unsigned long>(value), 0x10, result, prefix, width, '0');
uIntToStr(static_cast<unsigned long>(value), 0x10, result, prefix, width, '0', 0, upper);
return result;
}
@@ -652,18 +652,18 @@ inline std::string NumberFormatter::format0(unsigned long value, int width)
}
inline std::string NumberFormatter::formatHex(unsigned long value, bool prefix)
inline std::string NumberFormatter::formatHex(unsigned long value, bool prefix, bool upper)
{
std::string result;
uIntToStr(value, 0x10, result, prefix);
uIntToStr(value, 0x10, result, prefix, -1, ' ', 0, upper);
return result;
}
inline std::string NumberFormatter::formatHex(unsigned long value, int width, bool prefix)
inline std::string NumberFormatter::formatHex(unsigned long value, int width, bool prefix, bool upper)
{
std::string result;
uIntToStr(value, 0x10, result, prefix, width, '0');
uIntToStr(value, 0x10, result, prefix, width, '0', 0, upper);
return result;
}
@@ -696,18 +696,18 @@ inline std::string NumberFormatter::format0(long long value, int width)
}
inline std::string NumberFormatter::formatHex(long long value, bool prefix)
inline std::string NumberFormatter::formatHex(long long value, bool prefix, bool upper)
{
std::string result;
uIntToStr(static_cast<unsigned long long>(value), 0x10, result, prefix);
uIntToStr(static_cast<unsigned long long>(value), 0x10, result, prefix, -1, ' ', 0, upper);
return result;
}
inline std::string NumberFormatter::formatHex(long long value, int width, bool prefix)
inline std::string NumberFormatter::formatHex(long long value, int width, bool prefix, bool upper)
{
std::string result;
uIntToStr(static_cast<unsigned long long>(value), 0x10, result, prefix, width, '0');
uIntToStr(static_cast<unsigned long long>(value), 0x10, result, prefix, width, '0', 0, upper);
return result;
}
@@ -736,18 +736,18 @@ inline std::string NumberFormatter::format0(unsigned long long value, int width)
}
inline std::string NumberFormatter::formatHex(unsigned long long value, bool prefix)
inline std::string NumberFormatter::formatHex(unsigned long long value, bool prefix, bool upper)
{
std::string result;
uIntToStr(value, 0x10, result, prefix);
uIntToStr(value, 0x10, result, prefix, -1, ' ', 0, upper);
return result;
}
inline std::string NumberFormatter::formatHex(unsigned long long value, int width, bool prefix)
inline std::string NumberFormatter::formatHex(unsigned long long value, int width, bool prefix, bool upper)
{
std::string result;
uIntToStr(value, 0x10, result, prefix, width, '0');
uIntToStr(value, 0x10, result, prefix, width, '0', 0, upper);
return result;
}
@@ -779,18 +779,18 @@ inline std::string NumberFormatter::format0(Int64 value, int width)
}
inline std::string NumberFormatter::formatHex(Int64 value, bool prefix)
inline std::string NumberFormatter::formatHex(Int64 value, bool prefix, bool upper)
{
std::string result;
uIntToStr(static_cast<UInt64>(value), 0x10, result, prefix);
uIntToStr(static_cast<UInt64>(value), 0x10, result, prefix, -1, ' ', 0, upper);
return result;
}
inline std::string NumberFormatter::formatHex(Int64 value, int width, bool prefix)
inline std::string NumberFormatter::formatHex(Int64 value, int width, bool prefix, bool upper)
{
std::string result;
uIntToStr(static_cast<UInt64>(value), 0x10, result, prefix, width, '0');
uIntToStr(static_cast<UInt64>(value), 0x10, result, prefix, width, '0', 0, upper);
return result;
}
@@ -819,18 +819,18 @@ inline std::string NumberFormatter::format0(UInt64 value, int width)
}
inline std::string NumberFormatter::formatHex(UInt64 value, bool prefix)
inline std::string NumberFormatter::formatHex(UInt64 value, bool prefix, bool upper)
{
std::string result;
uIntToStr(value, 0x10, result, prefix);
uIntToStr(value, 0x10, result, prefix, -1, ' ', 0, upper);
return result;
}
inline std::string NumberFormatter::formatHex(UInt64 value, int width, bool prefix)
inline std::string NumberFormatter::formatHex(UInt64 value, int width, bool prefix, bool upper)
{
std::string result;
uIntToStr(value, 0x10, result, prefix, width, '0');
uIntToStr(value, 0x10, result, prefix, width, '0', 0, upper);
return result;
}