No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 

57 líneas
1.7 KiB

  1. #pragma once
  2. #include <iostream>
  3. namespace cppcore
  4. {
  5. /**
  6. * @brief Helper class to print hexdumps.
  7. */
  8. struct hexdump
  9. {
  10. const void * data; //!< Data to dump.
  11. size_t len; //!< Number of bytes stored in data.
  12. size_t offset; //!< Offset to start numbering at (this will not affect the passed data pointer).
  13. size_t split; //!< Add extra colum after specified number of bytes.
  14. size_t newline; //!< Add new line after specified number of bytes.
  15. /**
  16. * Constructor.
  17. *
  18. * @param[in] p_data Data to dump.
  19. * @param[in] p_len Number of bytes stored in @data.
  20. * @param[in] p_offset Offset to start numbering at (this will not affect the passed data pointer).
  21. * @param[in] p_split Add extra colum after specified number of bytes.
  22. * @param[in] p_newline Add new line after specified number of bytes.
  23. */
  24. inline hexdump(
  25. const void * p_data,
  26. size_t p_len,
  27. size_t p_offset = 0,
  28. size_t p_split = 8,
  29. size_t p_newline = 16);
  30. /**
  31. * @pbrief Print the hexdump to the passed stream.
  32. */
  33. inline void print(std::ostream& os) const;
  34. };
  35. }
  36. namespace std
  37. {
  38. /**
  39. * @brief Write the helper class to stream using the << operator.
  40. */
  41. template<typename T_char, typename T_traits>
  42. inline basic_ostream<T_char, T_traits>& operator<< (
  43. basic_ostream<T_char, T_traits>& os,
  44. const cppcore::hexdump& d);
  45. }
  46. #include "hexdump.inl"