]> AND Private Git Repository - canny.git/blob - stc/exp/ml_stc_linux_make_v1.0/include/boost/exception/detail/object_hex_dump.hpp
Logo AND Algorithmique Numérique Distribuée

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