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_F0EE17BE6C1211DE87FF459155D89593
7 #define BOOST_EXCEPTION_F0EE17BE6C1211DE87FF459155D89593
8 
9 #include <boost/exception/info.hpp>
10 #include <errno.h>
11 #include <string.h>
12 
13 #ifndef BOOST_EXCEPTION_ENABLE_WARNINGS
14 #if __GNUC__*100+__GNUC_MINOR__>301
15 #pragma GCC system_header
16 #endif
17 #ifdef __clang__
18 #pragma clang system_header
19 #endif
20 #ifdef _MSC_VER
21 #pragma warning(push,1)
22 #pragma warning(disable:4996)
23 #endif
24 #endif
25 
26 namespace
27 boost
28     {
29     typedef error_info<struct errinfo_errno_,int> errinfo_errno;
30 
31     //Usage hint:
32     //if( c_function(....)!=0 )
33     //    BOOST_THROW_EXCEPTION(
34     //        failure() <<
35     //        errinfo_errno(errno) <<
36     //        errinfo_api_function("c_function") );
37     inline
38     std::string
to_string(errinfo_errno const & e)39     to_string( errinfo_errno const & e )
40         {
41         std::ostringstream tmp;
42         int v=e.value();
43         tmp  << '[' << error_info_name(e) << "] = " << v << ", \"" << strerror(v) << "\"\n";
44         return tmp.str();
45         }
46     }
47 
48 #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
49 #pragma warning(pop)
50 #endif
51 #endif
52