source:
vendors/XIOS/current/extern/boost/include/boost/exception/detail/object_hex_dump.hpp
@
3428
Last change on this file since 3428 was 3428, checked in by rblod, 12 years ago | |
---|---|
File size: 1.5 KB |
Line | |
---|---|
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 UUID_6F463AC838DF11DDA3E6909F56D89593 |
7 | #define UUID_6F463AC838DF11DDA3E6909F56D89593 |
8 | #if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) |
9 | #pragma GCC system_header |
10 | #endif |
11 | #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) |
12 | #pragma warning(push,1) |
13 | #endif |
14 | |
15 | #include <boost/exception/detail/type_info.hpp> |
16 | #include <iomanip> |
17 | #include <ios> |
18 | #include <string> |
19 | #include <sstream> |
20 | #include <cstdlib> |
21 | |
22 | namespace |
23 | boost |
24 | { |
25 | namespace |
26 | exception_detail |
27 | { |
28 | template <class T> |
29 | inline |
30 | std::string |
31 | object_hex_dump( T const & x, std::size_t max_size=16 ) |
32 | { |
33 | std::ostringstream s; |
34 | s << "type: " << type_name<T>() << ", size: " << sizeof(T) << ", dump: "; |
35 | std::size_t n=sizeof(T)>max_size?max_size:sizeof(T); |
36 | s.fill('0'); |
37 | s.width(2); |
38 | unsigned char const * b=reinterpret_cast<unsigned char const *>(&x); |
39 | s << std::setw(2) << std::hex << (unsigned int)*b; |
40 | for( unsigned char const * e=b+n; ++b!=e; ) |
41 | s << " " << std::setw(2) << std::hex << (unsigned int)*b; |
42 | return s.str(); |
43 | } |
44 | } |
45 | } |
46 | |
47 | #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) |
48 | #pragma warning(pop) |
49 | #endif |
50 | #endif |
Note: See TracBrowser
for help on using the repository browser.