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

Private GIT Repository
cdbc76c7782e5671a759484b736958a9783be32e
[canny.git] / stc / exp / ml_stc_linux_make_v1.0 / include / boost / system / system_error.hpp
1 //  Boost system_error.hpp  --------------------------------------------------//\r
2 \r
3 //  Copyright Beman Dawes 2006\r
4 \r
5 //  Distributed under the Boost Software License, Version 1.0. (See accompanying\r
6 //  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\r
7 \r
8 #ifndef BOOST_SYSTEM_ERROR_HPP\r
9 #define BOOST_SYSTEM_ERROR_HPP\r
10 \r
11 #include <string>\r
12 #include <stdexcept>\r
13 #include <cassert>\r
14 #include <boost/system/error_code.hpp>\r
15 \r
16 namespace boost\r
17 {\r
18   namespace system\r
19   {\r
20     //  class system_error  --------------------------------------------------//\r
21 \r
22     class system_error : public std::runtime_error\r
23     {\r
24     public:\r
25       system_error( error_code ec )\r
26           : std::runtime_error(""), m_error_code(ec) {}\r
27 \r
28       system_error( error_code ec, const std::string & what_arg )\r
29           : std::runtime_error(what_arg), m_error_code(ec) {}\r
30 \r
31       system_error( error_code ec, const char* what_arg )\r
32           : std::runtime_error(what_arg), m_error_code(ec) {}\r
33 \r
34       system_error( int ev, const error_category & ecat )\r
35           : std::runtime_error(""), m_error_code(ev,ecat) {}\r
36 \r
37       system_error( int ev, const error_category & ecat,\r
38         const std::string & what_arg )\r
39           : std::runtime_error(what_arg), m_error_code(ev,ecat) {}\r
40 \r
41       system_error( int ev, const error_category & ecat,\r
42         const char * what_arg )\r
43           : std::runtime_error(what_arg), m_error_code(ev,ecat) {}\r
44 \r
45       virtual ~system_error() throw() {}\r
46 \r
47       const error_code &  code() const throw() { return m_error_code; }\r
48       const char *        what() const throw();\r
49 \r
50     private:\r
51       error_code           m_error_code;\r
52       mutable std::string  m_what;\r
53     };\r
54 \r
55     //  implementation  ------------------------------------------------------//\r
56 \r
57     inline const char * system_error::what() const throw()\r
58     // see http://www.boost.org/more/error_handling.html for lazy build rationale\r
59     {\r
60       if ( m_what.empty() )\r
61       {\r
62         try\r
63         {\r
64           m_what = this->std::runtime_error::what();\r
65           if ( m_error_code )\r
66           {\r
67             if ( !m_what.empty() ) m_what += ": ";\r
68             m_what += m_error_code.message();\r
69           }\r
70         }\r
71         catch (...) { return std::runtime_error::what(); }\r
72       }\r
73       return m_what.c_str();\r
74     }\r
75 \r
76   } // namespace system\r
77 } // namespace boost\r
78 \r
79 #endif // BOOST_SYSTEM_ERROR_HPP\r
80 \r
81 \r