00001 00002 /* 00003 The Extended Integer (XInt) Library 00004 A fast, portable C++ library for multi-precision integer math 00005 Copyright 2010 by Chad Nelson 00006 00007 Distributed under the Boost Software License, Version 1.0. 00008 See accompanying file LICENSE_1_0.txt or copy at 00009 http://www.boost.org/LICENSE_1_0.txt 00010 00011 See http://www.boost.org/libs/xint for library home page. 00012 */ 00013 00018 #ifndef BOOST_INCLUDED_XINT_EXCEPTIONS_HPP 00019 #define BOOST_INCLUDED_XINT_EXCEPTIONS_HPP 00020 00021 #include <stdexcept> 00022 #include "detail/basic_types_and_includes.hpp" 00023 00024 namespace boost { 00025 namespace xint { 00026 00039 inline void on_exception(on_exception_t fn = on_exception_t()) { 00040 detail::exception_handler<>::fn = fn; 00041 } 00042 00044 namespace exceptions { 00045 00049 class invalid_argument: public std::invalid_argument { 00050 public: 00051 invalid_argument(const std::string& what="invalid argument"): 00052 std::invalid_argument(what) { } 00053 }; 00054 00058 class invalid_base: public std::invalid_argument { 00059 public: 00060 invalid_base(const std::string& what="invalid base"): invalid_argument(what) 00061 { } 00062 }; 00063 00067 class invalid_digit: public std::range_error { 00068 public: 00069 invalid_digit(const std::string& what="invalid digit"): range_error(what) 00070 { } 00071 }; 00072 00076 class invalid_modulus: public std::invalid_argument { 00077 public: 00078 invalid_modulus(const std::string& what="invalid modulus"): 00079 invalid_argument(what) { } 00080 }; 00081 00085 class divide_by_zero: public std::invalid_argument { 00086 public: 00087 divide_by_zero(const std::string& what="divide by zero error"): 00088 invalid_argument(what) { } 00089 }; 00090 00094 class cannot_represent: public std::invalid_argument { 00095 public: 00096 cannot_represent(const std::string& what= 00097 "cannot represent the requested value"): invalid_argument(what) { } 00098 }; 00099 00103 class too_big: public std::range_error { 00104 public: 00105 too_big(const std::string& what= 00106 "value out of range for requested conversion"): range_error(what) { } 00107 }; 00108 00112 class not_a_number: public std::runtime_error { 00113 public: 00114 not_a_number(const std::string& what="attempted to use a Not-a-Number"): 00115 runtime_error(what) { } 00116 }; 00117 00127 class no_strong_random: public std::runtime_error { 00128 public: 00129 no_strong_random(const std::string& what= 00130 "system does not have a strong random generator"): 00131 runtime_error(what) { } 00132 }; 00133 00140 class overflow_error: public std::overflow_error { 00141 public: 00142 overflow_error(const std::string& what= 00143 "overflow error: can't obtain enough memory to represent the requested number"): 00144 std::overflow_error(what) { } 00145 }; 00146 00147 } // namespace exception 00148 } // namespace xint 00149 } // namespace boost 00150 00151 #endif // BOOST_INCLUDED_XINT_EXCEPTIONS_HPP
© Copyright Chad Nelson, 2010-2011. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)