| 1 | //Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. |
| 2 | |
| 3 | //Distributed under the Boost Software License, Version 1.0. (See accompanying |
| 4 | //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 5 | |
| 6 | #ifndef BOOST_EXCEPTION_6F463AC838DF11DDA3E6909F56D89593 |
| 7 | #define BOOST_EXCEPTION_6F463AC838DF11DDA3E6909F56D89593 |
| 8 | |
| 9 | #include <boost/exception/detail/type_info.hpp> |
| 10 | #include <iomanip> |
| 11 | #include <ios> |
| 12 | #include <string> |
| 13 | #include <sstream> |
| 14 | #include <cstdlib> |
| 15 | |
| 16 | #ifndef BOOST_EXCEPTION_ENABLE_WARNINGS |
| 17 | #if __GNUC__*100+__GNUC_MINOR__>301 |
| 18 | #pragma GCC system_header |
| 19 | #endif |
| 20 | #ifdef __clang__ |
| 21 | #pragma clang system_header |
| 22 | #endif |
| 23 | #ifdef _MSC_VER |
| 24 | #pragma warning(push,1) |
| 25 | #endif |
| 26 | #endif |
| 27 | |
| 28 | namespace |
| 29 | boost |
| 30 | { |
| 31 | namespace |
| 32 | exception_detail |
| 33 | { |
| 34 | template <class T> |
| 35 | inline |
| 36 | std::string |
| 37 | object_hex_dump( T const & x, std::size_t max_size=16 ) |
| 38 | { |
| 39 | std::ostringstream s; |
| 40 | s << "type: " << type_name<T>() << ", size: " << sizeof(T) << ", dump: " ; |
| 41 | std::size_t n=sizeof(T)>max_size?max_size:sizeof(T); |
| 42 | s.fill(ch: '0'); |
| 43 | s.width(wide: 2); |
| 44 | unsigned char const * b=reinterpret_cast<unsigned char const *>(&x); |
| 45 | s << std::setw(2) << std::hex << (unsigned int)*b; |
| 46 | for( unsigned char const * e=b+n; ++b!=e; ) |
| 47 | s << " " << std::setw(2) << std::hex << (unsigned int)*b; |
| 48 | return s.str(); |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) |
| 54 | #pragma warning(pop) |
| 55 | #endif |
| 56 | #endif |
| 57 | |