]> git.tdb.fi Git - libs/core.git/blob - source/stringcodec/except.h
Modernize noexcept specifiers
[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 };
18
19
20 /**
21 Thrown when a codec can't encode the requested character.
22 */
23 class invalid_character: public codec_error
24 {
25 public:
26         invalid_character(unichar, const std::string &);
27 };
28
29
30 /**
31 Thrown when a codec encounters a byte sequence it can't decode.
32 */
33 class invalid_sequence: public codec_error
34 {
35 public:
36         invalid_sequence(const std::string::const_iterator &, const std::string::const_iterator &, const std::string &);
37
38 private:
39         std::string format_sequence(const std::string::const_iterator &, const std::string::const_iterator &);
40 };
41
42 } // namespace StringCodec
43 } // namespace Msp
44
45 #endif