![]() |
General Utility Library for C++17 25.4.1
|
Hexadecimal dump of data.
Classes | |
class | gul17::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 | gul17::hexdump (IteratorT begin, IteratorT end, std::string_view prompt="") |
Generate a hexdump of a data range and return it as a string. | |
template<typename ContainerT , typename = std::enable_if_t<detail::IsHexDumpContainer<ContainerT>::value>> | |
std::string | gul17::hexdump (const ContainerT &cont, std::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. | |
template<typename IteratorT , typename = std::enable_if_t<detail::IsHexDumpIterator<IteratorT>::value>> | |
HexdumpParameterForward< const IteratorT > | gul17::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<<. | |
template<typename ContainerT , typename = std::enable_if_t<detail::IsHexDumpContainer<ContainerT>::value>> | |
HexdumpParameterForward< const decltype(std::declval< ContainerT >().cbegin())> | gul17::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. | |
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 > | gul17::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. | |
std::string gul17::hexdump | ( | const ContainerT & | cont, |
std::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 | (std::optional) String that prefixes the dump text |
References gul17::bit_set().
std::string gul17::hexdump | ( | IteratorT | begin, |
IteratorT | end, | ||
std::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 std::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 | (std::optional) String that prefixes the dump text |
References gul17::bit_set().
HexdumpParameterForward< const decltype(std::declval< ContainerT >().cbegin())> gul17::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 | (std::optional) String that prefixes the dump text |
References gul17::bit_set().
HexdumpParameterForward< const IteratorT > gul17::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 std::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 | (std::optional) String that prefixes the dump text |
References gul17::bit_set().
HexdumpParameterForward< decltype(std::declval< ContainerT >().cbegin()), ContainerT > gul17::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 | (std::optional) String that prefixes the dump text |
References gul17::bit_set().