X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fstrings%2Flexicalcast.h;h=b6cba3b89498c32b86576c66087d9472a0a4c680;hb=d16185720fa344263367dbd50c61bfc8183d99a4;hp=3bfc342a1f584e91cc218eb24b226c7a29c777da;hpb=b56eb5ec1da675da0c66abc53c1e4f6c4e4cccbd;p=libs%2Fcore.git diff --git a/source/strings/lexicalcast.h b/source/strings/lexicalcast.h index 3bfc342..b6cba3b 100644 --- a/source/strings/lexicalcast.h +++ b/source/strings/lexicalcast.h @@ -1,16 +1,9 @@ -/* $Id$ - -This file is part of libmspstrings -Copyright © 2006-2008 Mikko Rasa -Distributed under the LGPL -*/ - #ifndef MSP_STRINGS_LEXICALCAST_H_ #define MSP_STRINGS_LEXICALCAST_H_ #include #include -#include +#include #include "fmt.h" namespace Msp { @@ -18,10 +11,19 @@ namespace Msp { /** Thrown for errors in lexical conversions */ -class LexicalError: public Exception +class lexical_error: public std::runtime_error +{ +public: + lexical_error(const std::string &w): runtime_error(w) { } + virtual ~lexical_error() throw() { } +}; + + +class format_mismatch: public lexical_error { public: - LexicalError(const std::string &w_): Exception(w_) { } + format_mismatch(const std::string &w): lexical_error(w) { } + virtual ~format_mismatch() throw() { } }; @@ -101,7 +103,7 @@ void operator>>(const LexicalConverter &c, T &v) ss.setf(std::ios_base::fmtflags(0), std::ios_base::skipws); ss>>v; if(ss.fail() || !ss.eof()) - throw LexicalError("Conversion failure"); + throw lexical_error("conversion failure"); } // The main interface to the lexical conversion machinery