|
- #pragma once
-
- #include <iostream>
-
- namespace cppcore
- {
-
- /**
- * @brief Helper class to print hexdumps.
- */
- struct hexdump
- {
- const void * data; //!< Data to dump.
- size_t len; //!< Number of bytes stored in data.
- size_t offset; //!< Offset to start numbering at (this will not affect the passed data pointer).
- size_t split; //!< Add extra colum after specified number of bytes.
- size_t newline; //!< Add new line after specified number of bytes.
-
- /**
- * Constructor.
- *
- * @param[in] p_data Data to dump.
- * @param[in] p_len Number of bytes stored in @data.
- * @param[in] p_offset Offset to start numbering at (this will not affect the passed data pointer).
- * @param[in] p_split Add extra colum after specified number of bytes.
- * @param[in] p_newline Add new line after specified number of bytes.
- */
- inline hexdump(
- const void * p_data,
- size_t p_len,
- size_t p_offset = 0,
- size_t p_split = 8,
- size_t p_newline = 16);
-
- /**
- * @pbrief Print the hexdump to the passed stream.
- */
- inline void print(std::ostream& os) const;
- };
-
- }
-
- namespace std
- {
-
- /**
- * @brief Write the helper class to stream using the << operator.
- */
- template<typename T_char, typename T_traits>
- inline basic_ostream<T_char, T_traits>& operator<< (
- basic_ostream<T_char, T_traits>& os,
- const cppcore::hexdump& d);
-
- }
-
- #include "hexdump.inl"
|