VirtualBox

source: vbox/trunk/src/libs/boost-1.37.0/boost/exception/detail/object_hex_dump.hpp@ 37106

Last change on this file since 37106 was 16204, checked in by vboxsync, 16 years ago

export the boost stuff required for Main

File size: 1.2 KB
Line 
1//Copyright (c) 2006-2008 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
9#include <boost/exception/detail/type_info.hpp>
10#include <iomanip>
11#include <ios>
12#include <string>
13#include <sstream>
14
15namespace
16boost
17 {
18 namespace
19 exception_detail
20 {
21 template <class T>
22 inline
23 std::string
24 object_hex_dump( T const & x, size_t max_size=16 )
25 {
26 std::ostringstream s;
27 s << "type: " << type_name<T>() << ", size: " << sizeof(T) << ", dump: ";
28 size_t n=sizeof(T)>max_size?max_size:sizeof(T);
29 s.fill('0');
30 s.width(2);
31 unsigned char const * b=reinterpret_cast<unsigned char const *>(&x);
32 s << std::setw(2) << std::hex << (unsigned int)*b;
33 for( unsigned char const * e=b+n; ++b!=e; )
34 s << " " << std::setw(2) << std::hex << (unsigned int)*b;
35 return s.str();
36 }
37 }
38 }
39
40#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette