enh(NumberFormatter): Introduce backward compatible options for formatHex functions (#4333)

* enh(NumberFormatter): Introduce backward compatible options for formatHex functions.

* enh(NumberFormatter): Corrections and improvements suggested in code review.

* fix(ci): disable testEncryptDecryptGCM on macOS which often fails.

* enh(NumberFormatter): Improved naming.
This commit is contained in:
Matej Kenda
2023-12-15 18:30:55 +01:00
committed by GitHub
parent a464a4eabf
commit 111fe90dd9
6 changed files with 532 additions and 198 deletions

View File

@@ -43,6 +43,17 @@ public:
FMT_ON_OFF
};
enum class Options
/// Options to control the format of the generated string.
{
DEFAULT = 0,
/// formatHex defaults: No 0x prefix, uppercase hexadecimal values
PREFIX = 1 << 0,
/// formatHex: Prepend prefix 0x
LOWERCASE = 1 << 1
/// formatHex: Use lowercase letters for hexadecimal values
};
static const unsigned NF_MAX_INT_STRING_LEN = 32; // increase for 64-bit binary formatting support
static const unsigned NF_MAX_FLT_STRING_LEN = POCO_MAX_FLT_STRING_LEN;
@@ -59,18 +70,18 @@ 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, Options options = Options::DEFAULT);
/// Formats an int value in hexadecimal notation.
/// If prefix is true, "0x" prefix is prepended to the
/// resulting string.
/// Options (see NumberFormatter::Options) define the format of the
/// generated string.
/// The value is treated as unsigned.
static std::string formatHex(int value, int width, bool prefix = false);
/// Formats a int value in hexadecimal notation,
static std::string formatHex(int value, int width, Options options = Options::DEFAULT);
/// Formats an int 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 prepended to the
/// resulting string.
/// Options (see NumberFormatter::Options) define the format of the
/// generated string.
/// The value is treated as unsigned.
static std::string format(unsigned value);
@@ -86,17 +97,17 @@ 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, Options options = Options::DEFAULT);
/// Formats an unsigned int value in hexadecimal notation.
/// If prefix is true, "0x" prefix is prepended to the
/// resulting string.
/// Options (see NumberFormatter::Options) define the format of the
/// generated string.
static std::string formatHex(unsigned value, int width, bool prefix = false);
/// Formats a int value in hexadecimal notation,
static std::string formatHex(unsigned value, int width, Options options = Options::DEFAULT);
/// Formats an unsigned 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 prepended to the
/// resulting string.
/// Options (see NumberFormatter::Options) define the format of the
/// generated string.
static std::string format(long value);
/// Formats a long value in decimal notation.
@@ -111,19 +122,17 @@ public:
/// right justified and zero-padded in a field
/// having at least the specified width.
static std::string formatHex(long value, bool prefix = false);
/// 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, Options options = Options::DEFAULT);
/// Formats a long value in hexadecimal notation.
/// Options (see NumberFormatter::Options) define the format of the
/// generated string.
static std::string formatHex(long value, int width, bool prefix = false);
/// Formats an unsigned long 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 prepended to the
/// resulting string.
/// The value is treated as unsigned.
static std::string formatHex(long value, int width, Options options = Options::DEFAULT);
/// Formats a long value in hexadecimal notation,
/// right justified and zero-padded in
/// a field having at least the specified width.
/// Options (see NumberFormatter::Options) define the format of the
/// generated string.
static std::string format(unsigned long value);
/// Formats an unsigned long value in decimal notation.
@@ -138,17 +147,17 @@ 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, Options options = Options::DEFAULT);
/// Formats an unsigned long value in hexadecimal notation.
/// If prefix is true, "0x" prefix is prepended to the
/// resulting string.
/// Options (see NumberFormatter::Options) define the format of the
/// generated string.
static std::string formatHex(unsigned long value, int width, bool prefix = false);
static std::string formatHex(unsigned long value, int width, Options options = Options::DEFAULT);
/// Formats an unsigned long 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 prepended to the
/// resulting string.
/// right justified and zero-padded in
/// a field having at least the specified width.
/// Options (see NumberFormatter::Options) define the format of the
/// generated string.
#ifdef POCO_HAVE_INT64
#ifdef POCO_INT64_IS_LONG
@@ -165,18 +174,18 @@ 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, Options options = Options::DEFAULT);
/// 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.
/// Options (see NumberFormatter::Options) define the format of the
/// generated string.
static std::string formatHex(long long value, int width, bool prefix = false);
static std::string formatHex(long long value, int width, Options options = Options::DEFAULT);
/// Formats a 64-bit integer value in hexadecimal notation,
/// right justified and zero-padded in a field having at least
/// the specified width.
/// The value is treated as unsigned.
/// If prefix is true, "0x" prefix is prepended to the resulting string.
/// Options (see NumberFormatter::Options) define the format of the
/// generated string.
static std::string format(unsigned long long value);
/// Formats an unsigned 64-bit integer value in decimal notation.
@@ -190,16 +199,18 @@ 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);
/// 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, Options options = Options::DEFAULT);
/// Formats an unsigned 64-bit value in hexadecimal notation.
/// Options (see NumberFormatter::Options) define the format of the
/// generated string.
static std::string formatHex(unsigned long long value, int width, bool prefix = false);
/// Formats a 64-bit integer value in hexadecimal notation,
static std::string formatHex(unsigned long long value, int width, Options options = Options::DEFAULT);
/// Formats an unsigned 64-bit 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
/// prepended to the resulting string.
/// the specified width.
/// The value is treated as unsigned.
/// Options (see NumberFormatter::Options) define the format of the
/// generated string.
#else // ifndef POCO_INT64_IS_LONG
@@ -215,18 +226,18 @@ 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, Options options = Options::DEFAULT);
/// 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.
/// Options (see NumberFormatter::Options) define the format of the
/// generated string.
static std::string formatHex(Int64 value, int width, bool prefix = false);
static std::string formatHex(Int64 value, int width, Options options = Options::DEFAULT);
/// Formats a 64-bit integer value in hexadecimal notation,
/// right justified and zero-padded in a field having at least
/// the specified width.
/// The value is treated as unsigned.
/// If prefix is true, "0x" prefix is prepended to the resulting string.
/// Options (see NumberFormatter::Options) define the format of the
/// generated string.
static std::string format(UInt64 value);
/// Formats an unsigned 64-bit integer value in decimal notation.
@@ -240,16 +251,18 @@ public:
/// right justified and zero-padded in a field having at least the
/// specified width.
static std::string formatHex(UInt64 value, bool prefix = false);
/// 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, Options options = Options::DEFAULT);
/// Formats an unsigned 64-bit integer in hexadecimal notation.
/// Options (see NumberFormatter::Options) define the format of the
/// generated string.
static std::string formatHex(UInt64 value, int width, bool prefix = false);
/// Formats a 64-bit integer value in hexadecimal notation,
static std::string formatHex(UInt64 value, int width, Options options = Options::DEFAULT);
/// Formats an unsigned 64-bit integer in hexadecimal notation,
/// right justified and zero-padded in a field having at least
/// the specified width. If prefix is true, "0x" prefix is
/// prepended to the resulting string.
/// the specified width.
/// The value is treated as unsigned.
/// Options (see NumberFormatter::Options) define the format of the
/// generated string.
#endif // ifdef POCO_INT64_IS_LONG
#endif // ifdef POCO_HAVE_INT64
@@ -325,10 +338,10 @@ public:
/// right justified and zero-padded in a field having at
/// least the specified width.
static void appendHex(std::string& str, unsigned value);
static void appendHex(std::string& str, unsigned value, bool lowercase = false);
/// Formats an unsigned int value in hexadecimal notation.
static void appendHex(std::string& str, unsigned value, int width);
static void appendHex(std::string& str, unsigned value, int width, bool lowercase = false);
/// Formats a int value in hexadecimal notation,
/// right justified and zero-padded in
/// a field having at least the specified width.
@@ -346,11 +359,11 @@ public:
/// right justified and zero-padded in a field
/// having at least the specified width.
static void appendHex(std::string& str, long value);
static void appendHex(std::string& str, long value, bool lowercase = false);
/// Formats an unsigned long value in hexadecimal notation.
/// The value is treated as unsigned.
static void appendHex(std::string& str, long value, int width);
static void appendHex(std::string& str, long value, int width, bool lowercase = false);
/// Formats an unsigned long value in hexadecimal notation,
/// right justified and zero-padded in a field having at least the
/// specified width.
@@ -369,10 +382,10 @@ public:
/// right justified and zero-padded
/// in a field having at least the specified width.
static void appendHex(std::string& str, unsigned long value);
static void appendHex(std::string& str, unsigned long value, bool lowercase = false);
/// Formats an unsigned long value in hexadecimal notation.
static void appendHex(std::string& str, unsigned long value, int width);
static void appendHex(std::string& str, unsigned long value, int width, bool lowercase = false);
/// Formats an unsigned long value in hexadecimal notation,
/// right justified and zero-padded in a field having at least the
/// specified width.
@@ -392,11 +405,11 @@ public:
/// right justified and zero-padded in a field having at least
/// the specified width.
static void appendHex(std::string& str, long long value);
static void appendHex(std::string& str, long long value, bool lowercase = false);
/// Formats a 64-bit integer value in hexadecimal notation.
/// The value is treated as unsigned.
static void appendHex(std::string& str, long long value, int width);
static void appendHex(std::string& str, long long value, int width, bool lowercase = false);
/// Formats a 64-bit integer value in hexadecimal notation,
/// right justified and zero-padded in a field having at least
/// the specified width.
@@ -414,10 +427,10 @@ public:
/// right justified and zero-padded in a field having at least the
/// specified width.
static void appendHex(std::string& str, unsigned long long value);
static void appendHex(std::string& str, unsigned long long value, bool lowercase = false);
/// Formats a 64-bit integer value in hexadecimal notation.
static void appendHex(std::string& str, unsigned long long value, int width);
static void appendHex(std::string& str, unsigned long long value, int width, bool lowercase = false);
/// Formats a 64-bit integer value in hexadecimal notation,
/// right justified and zero-padded in a field having at least
/// the specified width.
@@ -436,11 +449,11 @@ public:
/// right justified and zero-padded in a field having at least
/// the specified width.
static void appendHex(std::string& str, Int64 value);
static void appendHex(std::string& str, Int64 value, bool lowercase = false);
/// Formats a 64-bit integer value in hexadecimal notation.
/// The value is treated as unsigned.
static void appendHex(std::string& str, Int64 value, int width);
static void appendHex(std::string& str, Int64 value, int width, bool lowercase = false);
/// Formats a 64-bit integer value in hexadecimal notation,
/// right justified and zero-padded in a field having at least
/// the specified width.
@@ -458,10 +471,10 @@ public:
/// right justified and zero-padded in a field having at least the
/// specified width.
static void appendHex(std::string& str, UInt64 value);
static void appendHex(std::string& str, UInt64 value, bool lowercase = false);
/// Formats a 64-bit integer value in hexadecimal notation.
static void appendHex(std::string& str, UInt64 value, int width);
static void appendHex(std::string& str, UInt64 value, int width, bool lowercase = false);
/// Formats a 64-bit integer value in hexadecimal notation,
/// right justified and zero-padded in a field having at least
/// the specified width.
@@ -500,7 +513,137 @@ public:
/// sixteen (64-bit architectures) characters wide
/// field in hexadecimal notation.
//
// Deprecated functions
//
[[deprecated("use formatHex with options instead")]]
static std::string formatHex(int value, bool prefix);
/// 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.
[[deprecated("use formatHex with options instead")]]
static std::string formatHex(int value, int width, bool prefix);
/// Formats an int 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 prepended to the
/// resulting string.
/// The value is treated as unsigned.
[[deprecated("use formatHex with options instead")]]
static std::string formatHex(unsigned value, bool prefix);
/// Formats an unsigned int value in hexadecimal notation.
/// If prefix is true, "0x" prefix is prepended to the
/// resulting string.
[[deprecated("use formatHex with options instead")]]
static std::string formatHex(unsigned value, int width, bool prefix);
/// Formats an unsigned 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 prepended to the
/// resulting string.
[[deprecated("use formatHex with options instead")]]
static std::string formatHex(long value, bool prefix);
/// Formats a long value in hexadecimal notation.
/// If prefix is true, "0x" prefix is prepended to the
/// resulting string.
/// The value is treated as unsigned.
[[deprecated("use formatHex with options instead")]]
static std::string formatHex(long value, int width, bool prefix);
/// Formats a long 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 prepended to the
/// resulting string.
/// The value is treated as unsigned.
[[deprecated("use formatHex with options instead")]]
static std::string formatHex(unsigned long value, bool prefix);
/// Formats an unsigned long value in hexadecimal notation.
/// If prefix is true, "0x" prefix is prepended to the
/// resulting string.
[[deprecated("use formatHex with options instead")]]
static std::string formatHex(unsigned long value, int width, bool prefix);
/// Formats an unsigned long 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 prepended to the
/// resulting string.
#ifdef POCO_HAVE_INT64
#ifdef POCO_INT64_IS_LONG
[[deprecated("use formatHex with options instead")]]
static std::string formatHex(long long value, bool prefix);
/// 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.
[[deprecated("use formatHex with options instead")]]
static std::string formatHex(long long value, int width, bool prefix);
/// Formats a 64-bit integer value in hexadecimal notation,
/// right justified and zero-padded in a field having at least
/// the specified width.
/// The value is treated as unsigned.
/// If prefix is true, "0x" prefix is prepended to the resulting string.
[[deprecated("use formatHex with options instead")]]
static std::string formatHex(unsigned long long value, bool prefix);
/// Formats an unsigned 64-bit integer value in hexadecimal notation.
/// If prefix is true, "0x" prefix is prepended to the
/// resulting string.
[[deprecated("use formatHex with options instead")]]
static std::string formatHex(unsigned long long value, int width, bool prefix);
/// Formats an unsigned 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
/// prepended to the resulting string.
#else // ifndef POCO_INT64_IS_LONG
[[deprecated("use formatHex with options instead")]]
static std::string formatHex(Int64 value, bool prefix);
/// 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.
[[deprecated("use formatHex with options instead")]]
static std::string formatHex(Int64 value, int width, bool prefix);
/// Formats a 64-bit integer value in hexadecimal notation,
/// right justified and zero-padded in a field having at least
/// the specified width.
/// The value is treated as unsigned.
/// If prefix is true, "0x" prefix is prepended to the resulting string.
[[deprecated("use formatHex with options instead")]]
static std::string formatHex(UInt64 value, bool prefix);
/// Formats an unsigned 64-bit integer value in hexadecimal notation.
/// If prefix is true, "0x" prefix is prepended to the
/// resulting string.
[[deprecated("use formatHex with options instead")]]
static std::string formatHex(UInt64 value, int width, bool prefix);
/// Formats an unsigned 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
/// prepended to the resulting string.
#endif // ifdef POCO_INT64_IS_LONG
#endif // ifdef POCO_HAVE_INT64
private:
static bool isEnabled(NumberFormatter::Options options, NumberFormatter::Options opt);
};
@@ -508,6 +651,42 @@ private:
// inlines
//
inline NumberFormatter::Options operator | (NumberFormatter::Options lhs, NumberFormatter::Options rhs)
{
using T = std::underlying_type_t<NumberFormatter::Options>;
return static_cast<NumberFormatter::Options>(static_cast<T>(lhs) | static_cast<T>(rhs));
}
inline NumberFormatter::Options& operator |= (NumberFormatter::Options& lhs, NumberFormatter::Options rhs)
{
lhs = lhs | rhs;
return lhs;
}
inline NumberFormatter::Options operator & (NumberFormatter::Options lhs, NumberFormatter::Options rhs)
{
using T = std::underlying_type_t<NumberFormatter::Options>;
return static_cast<NumberFormatter::Options>(static_cast<T>(lhs) & static_cast<T>(rhs));
}
inline NumberFormatter::Options& operator &= (NumberFormatter::Options& lhs, NumberFormatter::Options rhs)
{
lhs = lhs & rhs;
return lhs;
}
inline bool NumberFormatter::isEnabled(Options options, Options opt)
{
using T = std::underlying_type_t<Options>;
return static_cast<T>(options & opt) != 0;
}
inline std::string NumberFormatter::format(int value)
{
std::string result;
@@ -532,19 +711,15 @@ 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, Options options)
{
std::string result;
intToStr(static_cast<unsigned int>(value), 0x10, result, prefix);
return result;
return formatHex(static_cast<unsigned int>(value), options);
}
inline std::string NumberFormatter::formatHex(int value, int width, bool prefix)
inline std::string NumberFormatter::formatHex(int value, int width, Options options)
{
std::string result;
intToStr(static_cast<unsigned int>(value), 0x10, result, prefix, width, '0');
return result;
return formatHex(static_cast<unsigned int>(value), width, options);
}
@@ -572,18 +747,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, Options options)
{
std::string result;
intToStr(value, 0x10, result, prefix);
intToStr(value, 0x10, result, isEnabled(options, Options::PREFIX),-1, ' ', 0, isEnabled(options, Options::LOWERCASE));
return result;
}
inline std::string NumberFormatter::formatHex(unsigned value, int width, bool prefix)
inline std::string NumberFormatter::formatHex(unsigned value, int width, Options options)
{
std::string result;
intToStr(value, 0x10, result, prefix, width, '0');
intToStr(value, 0x10, result, isEnabled(options, Options::PREFIX), width, '0', 0, isEnabled(options, Options::LOWERCASE));
return result;
}
@@ -612,19 +787,15 @@ 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, Options options)
{
std::string result;
intToStr(static_cast<unsigned long>(value), 0x10, result, prefix);
return result;
return formatHex(static_cast<unsigned long>(value), options);
}
inline std::string NumberFormatter::formatHex(long value, int width, bool prefix)
inline std::string NumberFormatter::formatHex(long value, int width, Options options)
{
std::string result;
intToStr(static_cast<unsigned long>(value), 0x10, result, prefix, width, '0');
return result;
return formatHex(static_cast<unsigned long>(value), width, options);
}
@@ -652,22 +823,21 @@ 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, Options options)
{
std::string result;
intToStr(value, 0x10, result, prefix);
intToStr(value, 0x10, result, isEnabled(options, Options::PREFIX), -1, ' ', 0, isEnabled(options, Options::LOWERCASE));
return result;
}
inline std::string NumberFormatter::formatHex(unsigned long value, int width, bool prefix)
inline std::string NumberFormatter::formatHex(unsigned long value, int width, Options options)
{
std::string result;
intToStr(value, 0x10, result, prefix, width, '0');
intToStr(value, 0x10, result, isEnabled(options, Options::PREFIX), width, '0', 0, isEnabled(options, Options::LOWERCASE));
return result;
}
#ifdef POCO_HAVE_INT64
#ifdef POCO_INT64_IS_LONG
@@ -696,19 +866,15 @@ 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, Options options)
{
std::string result;
intToStr(static_cast<unsigned long long>(value), 0x10, result, prefix);
return result;
return formatHex(static_cast<unsigned long long>(value), options);
}
inline std::string NumberFormatter::formatHex(long long value, int width, bool prefix)
inline std::string NumberFormatter::formatHex(long long value, int width, Options options)
{
std::string result;
intToStr(static_cast<unsigned long long>(value), 0x10, result, prefix, width, '0');
return result;
return formatHex(static_cast<unsigned long long>(value), width, options);
}
@@ -736,18 +902,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, Options options)
{
std::string result;
intToStr(value, 0x10, result, prefix);
intToStr(value, 0x10, result, isEnabled(options, Options::PREFIX), -1, ' ', 0, isEnabled(options, Options::LOWERCASE));
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, Options options)
{
std::string result;
intToStr(value, 0x10, result, prefix, width, '0');
intToStr(value, 0x10, result, isEnabled(options, Options::PREFIX), width, '0', 0, isEnabled(options, Options::LOWERCASE));
return result;
}
@@ -779,19 +945,15 @@ 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, Options options)
{
std::string result;
intToStr(static_cast<UInt64>(value), 0x10, result, prefix);
return result;
return formatHex(static_cast<UInt64>(value), options);
}
inline std::string NumberFormatter::formatHex(Int64 value, int width, bool prefix)
inline std::string NumberFormatter::formatHex(long long value, int width, Options options)
{
std::string result;
intToStr(static_cast<UInt64>(value), 0x10, result, prefix, width, '0');
return result;
return formatHex(static_cast<UInt64>(value), width, options);
}
@@ -819,18 +981,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, Options options)
{
std::string result;
intToStr(value, 0x10, result, prefix);
intToStr(value, 0x10, result, isEnabled(options, Options::PREFIX), -1, ' ', 0, isEnabled(options, Options::LOWERCASE));
return result;
}
inline std::string NumberFormatter::formatHex(UInt64 value, int width, bool prefix)
inline std::string NumberFormatter::formatHex(UInt64 value, int width, Options options)
{
std::string result;
intToStr(value, 0x10, result, prefix, width, '0');
intToStr(value, 0x10, result, isEnabled(options, Options::PREFIX), width, '0', 0, isEnabled(options, Options::LOWERCASE));
return result;
}