Commit 733e2638 authored by Martin Marinov's avatar Martin Marinov
Browse files

Implement Base::format_hex() for all 32 and 64 bit types

parent 33c61790
......@@ -223,6 +223,7 @@ inline FormatT<> format(const char* const _frmt, const T& _vrbl)
return FormatT<>(_frmt, _vrbl);
}
//! Format a 32bit uint variable for streaming in hex (e.g. for hash)
inline FormatT<> format_hex(const uint32_t _vrbl)
{
......@@ -235,5 +236,15 @@ inline FormatT<> format_hex(const uint64_t _vrbl)
return FormatT<>("%I64x", _vrbl);
}
template <typename T> //!< 32 or 64 bit type
inline FormatT<> format_hex(const T _vrbl)
{
template <int byte_nmbr> struct CastT;
struct CastT<4> { typedef uint32_t Type; };
struct CastT<8> { typedef uint64_t Type; };
return format_hex(CastT<sizeof(T)>::Type(_vrbl));
}
}//namespace Base
#endif//BASE_IOUTPUTSTREAM_HH_INCLUDE
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment