mqtt_cpp
hexdump.hpp
Go to the documentation of this file.
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 
7 #if !defined(MQTT_HEXDUMP_HPP)
8 #define MQTT_HEXDUMP_HPP
9 
10 #include <ostream>
11 #include <iomanip>
12 
13 #include <mqtt/namespace.hpp>
14 
15 namespace MQTT_NS {
16 
17 template <typename T>
18 inline void hexdump(std::ostream& os, T const& v) {
19  for (auto c : v) {
20  os << std::hex << std::setw(2) << std::setfill('0');
21  os << (static_cast<int>(c) & 0xff) << ' ';
22  }
23 }
24 
25 } // namespace MQTT_NS
26 
27 #endif // MQTT_HEXDUMP_HPP
Definition: any.hpp:27
void hexdump(std::ostream &os, T const &v)
Definition: hexdump.hpp:18