]> git.tdb.fi Git - libs/core.git/blob - source/stringcodec/except.h
Mark overridden virtual functions as such
[libs/core.git] / source / stringcodec / except.h
1 #ifndef MSP_STRINGCODEC_EXCEPT_H_
2 #define MSP_STRINGCODEC_EXCEPT_H_
3
4 #include <stdexcept>
5 #include "ustring.h"
6
7 namespace Msp {
8 namespace StringCodec {
9
10 /**
11 Base class for codec errors.
12 */
13 class codec_error: public std::runtime_error
14 {
15 public:
16         codec_error(const std::string &w): std::runtime_error(w) { }
17         ~codec_error() throw() override = default;
18 };
19
20
21 /**
22 Thrown when a codec can't encode the requested character.
23 */
24 class invalid_character: public codec_error
25 {
26 public:
27         invalid_character(unichar, const std::string &);
28         ~invalid_character() throw() override = default;
29 };
30
31
32 /**
33 Thrown when a codec encounters a byte sequence it can't decode.
34 */
35 class invalid_sequence: public codec_error
36 {
37 public:
38         invalid_sequence(const std::string::const_iterator &, const std::string::const_iterator &, const std::string &);
39         ~invalid_sequence() throw() override = default;
40
41 private:
42         std::string format_sequence(const std::string::const_iterator &, const std::string::const_iterator &);
43 };
44
45 } // namespace StringCodec
46 } // namespace Msp
47
48 #endif