General Utility Library for C++14
2.11
|
Hexadecimal dump of data.
Classes | |
class | gul14::HexdumpParameterForward< IteratorT, ContainerT > |
Helper object used to enable a convenient syntax to dump things to a stream. More... | |
Functions | |
template<typename IteratorT , typename = std::enable_if_t<detail::IsHexDumpIterator<IteratorT>::value>> | |
std::string | gul14::hexdump (IteratorT begin, IteratorT end, string_view prompt="") |
Generate a hexdump of a data range and return it as a string. More... | |
template<typename ContainerT , typename = std::enable_if_t<detail::IsHexDumpContainer<ContainerT>::value>> | |
std::string | gul14::hexdump (const ContainerT &cont, string_view prompt="") |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
template<typename IteratorT , typename = std::enable_if_t<detail::IsHexDumpIterator<IteratorT>::value>> | |
HexdumpParameterForward< const IteratorT > | gul14::hexdump_stream (const IteratorT &begin, const IteratorT &end, std::string prompt="") |
Generate a hexdump of a data range that can be efficiently written to a stream using operator<<. More... | |
template<typename ContainerT , typename = std::enable_if_t<detail::IsHexDumpContainer<ContainerT>::value>> | |
HexdumpParameterForward< const decltype(std::declval< ContainerT >).cbegin())> | gul14::hexdump_stream (const ContainerT &cont, std::string prompt="") |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
template<typename ContainerT , typename = std::enable_if_t<detail::IsHexDumpContainer<ContainerT>::value, decltype(HexdumpParameterForward<decltype(std::declval<ContainerT>().cbegin()), ContainerT> {}, 0)>> | |
HexdumpParameterForward< decltype(std::declval< ContainerT >).cbegin()), ContainerT > | gul14::hexdump_stream (ContainerT &&cont, std::string prompt="") |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
std::string gul14::hexdump | ( | const ContainerT & | cont, |
string_view | prompt = "" |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
cont | Reference to the container whose contents should be dumped; the container must provide ForwardIterators for .cbegin() and .cend() |
prompt | (optional) String that prefixes the dump text |
References gul14::hexdump_stream().
std::string gul14::hexdump | ( | IteratorT | begin, |
IteratorT | end, | ||
string_view | prompt = "" |
||
) |
Generate a hexdump of a data range and return it as a string.
The elements of the data range must be of integral type. They are dumped as unsigned integer values with their native width: Chars as "00" to "ff", 16-bit integers as "0000" to "ffff", and so on. If the elements are of type char, also a textual representation of the printable characters is dumped. An optional prompt can be added in front of the hexdump.
deBug -> 000000: 74 65 73 74 0a 74 68 65 20 c3 84 20 77 65 73 74 test.the .. west 000010: 21 09 0d 0a !...
000000: 00000000 00000001 00000005 00000002 cff00001 00000002 00000005 000007cf
begin | ForwardIterator to the first data element to be dumped |
end | ForwardIterator past the last data element to be dumped |
prompt | (optional) String that prefixes the dump text |
References gul14::hexdump_stream().
HexdumpParameterForward<const decltype(std::declval<ContainerT>).cbegin())> gul14::hexdump_stream | ( | const ContainerT & | cont, |
std::string | prompt = "" |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
cont | Reference to the container to dump |
prompt | (optional) String that prefixes the dump text |
HexdumpParameterForward<const IteratorT> gul14::hexdump_stream | ( | const IteratorT & | begin, |
const IteratorT & | end, | ||
std::string | prompt = "" |
||
) |
Generate a hexdump of a data range that can be efficiently written to a stream using operator<<.
Where hexdump() writes all of its output into one monolithic string, hexdump_stream() returns a tiny helper object that can efficiently send its output to an output stream via operator<<. This means that the following two lines produce the exact same output, but the stream version uses less resources:
The elements of the data range must be of integral type. They are dumped as unsigned integer values with their native width: Chars as "00" to "ff", 16-bit integers as "0000" to "ffff", and so on. If the elements are of type char, also a textual representation of the printable characters is dumped. An optional prompt can be added in front of the hexdump.
debug -> 000000: 74 65 73 74 0a 74 68 65 20 c3 84 20 77 65 73 74 test.the .. west 000010: 21 09 0d 0a !...
000000: 00000000 00000001 00000005 00000002 cff00001 00000002 00000005 000007cf
begin | ForwardIterator to the first data to be dumped |
end | ForwardIterator past the last data element to be dumped |
prompt | (optional) String that prefixes the dump text |
HexdumpParameterForward<decltype(std::declval<ContainerT>).cbegin()), ContainerT> gul14::hexdump_stream | ( | ContainerT && | cont, |
std::string | prompt = "" |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
cont | Reference to the container to dump if is a temporary |
prompt | (optional) String that prefixes the dump text |
Referenced by gul14::hexdump().