X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fstringcodec%2Fexcept.h;fp=source%2Fstringcodec%2Fexcept.h;h=6e2566682669ec0bbdc6a925d4fca2fb653c2250;hb=94ee3a1040f67d9de2e92fc34049642b08d65b3e;hp=0000000000000000000000000000000000000000;hpb=93bb92bad766d269a6bac87e00020a6158531739;p=libs%2Fcore.git diff --git a/source/stringcodec/except.h b/source/stringcodec/except.h new file mode 100644 index 0000000..6e25666 --- /dev/null +++ b/source/stringcodec/except.h @@ -0,0 +1,48 @@ +#ifndef MSP_STRINGCODEC_EXCEPT_H_ +#define MSP_STRINGCODEC_EXCEPT_H_ + +#include +#include "ustring.h" + +namespace Msp { +namespace StringCodec { + +/** +Base class for codec errors. +*/ +class codec_error: public std::runtime_error +{ +public: + codec_error(const std::string &w): std::runtime_error(w) { } + virtual ~codec_error() throw() { } +}; + + +/** +Thrown when a codec can't encode the requested character. +*/ +class invalid_character: public codec_error +{ +public: + invalid_character(unichar, const std::string &); + virtual ~invalid_character() throw() { } +}; + + +/** +Thrown when a codec encounters a byte sequence it can't decode. +*/ +class invalid_sequence: public codec_error +{ +public: + invalid_sequence(const std::string::const_iterator &, const std::string::const_iterator &, const std::string &); + virtual ~invalid_sequence() throw() { } + +private: + std::string format_sequence(const std::string::const_iterator &, const std::string::const_iterator &); +}; + +} // namespace StringCodec +} // namespace Msp + +#endif