hexdump.hpp 611 B

123456789101112131415161718192021222324252627
  1. // Copyright Takatoshi Kondo 2015
  2. //
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. #if !defined(MQTT_HEXDUMP_HPP)
  7. #define MQTT_HEXDUMP_HPP
  8. #include <ostream>
  9. #include <iomanip>
  10. #include <mqtt/namespace.hpp>
  11. namespace MQTT_NS {
  12. template <typename T>
  13. inline void hexdump(std::ostream& os, T const& v) {
  14. for (auto c : v) {
  15. os << std::hex << std::setw(2) << std::setfill('0');
  16. os << (static_cast<int>(c) & 0xff) << ' ';
  17. }
  18. }
  19. } // namespace MQTT_NS
  20. #endif // MQTT_HEXDUMP_HPP