mirror of
https://github.com/boostorg/algorithm.git
synced 2025-07-05 16:56:39 +02:00
Reworked boost::algorithm::unhex error reporting to play nicer with Boost.Exception (thanks to Emil); added tests
[SVN r78838]
This commit is contained in:
@ -51,14 +51,10 @@ namespace boost { namespace algorithm {
|
||||
\brief Thrown when the input sequence unexpectedly ends
|
||||
|
||||
*/
|
||||
struct hex_decode_error: virtual boost::exception, virtual std::exception {};
|
||||
struct not_enough_input : public hex_decode_error {};
|
||||
struct non_hex_input : public hex_decode_error {
|
||||
non_hex_input ( char ch ) : bad_char ( ch ) {}
|
||||
char bad_char;
|
||||
private:
|
||||
non_hex_input (); // don't allow creation w/o a char
|
||||
};
|
||||
struct hex_decode_error : virtual boost::exception, virtual std::exception {};
|
||||
struct not_enough_input : virtual hex_decode_error {};
|
||||
struct non_hex_input : virtual hex_decode_error {};
|
||||
typedef boost::error_info<struct bad_char_,char> bad_char;
|
||||
|
||||
namespace detail {
|
||||
/// \cond DOXYGEN_HIDE
|
||||
@ -77,7 +73,7 @@ namespace detail {
|
||||
if ( c >= '0' && c <= '9' ) return c - '0';
|
||||
if ( c >= 'A' && c <= 'F' ) return c - 'A' + 10;
|
||||
if ( c >= 'a' && c <= 'f' ) return c - 'a' + 10;
|
||||
BOOST_THROW_EXCEPTION (non_hex_input (c));
|
||||
BOOST_THROW_EXCEPTION (non_hex_input() << boost::algorithm::bad_char (c));
|
||||
return 0; // keep dumb compilers happy
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user