/
exceptions.h
79 lines (65 loc) · 2.75 KB
/
exceptions.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef TAG_PARSER_EXCEPTIONS_H
#define TAG_PARSER_EXCEPTIONS_H
#include "./global.h"
#include <stdexcept>
#include <string>
namespace TagParser {
class TAG_PARSER_EXPORT Failure : public std::exception {
public:
Failure() noexcept;
virtual ~Failure() noexcept;
virtual const char *what() const noexcept;
};
class TAG_PARSER_EXPORT NoDataFoundException : public Failure {
public:
NoDataFoundException() noexcept;
virtual ~NoDataFoundException() noexcept;
virtual const char *what() const noexcept;
};
class TAG_PARSER_EXPORT InvalidDataException : public Failure {
public:
InvalidDataException() noexcept;
virtual ~InvalidDataException() noexcept;
virtual const char *what() const noexcept;
};
class TAG_PARSER_EXPORT NoDataProvidedException : public Failure {
public:
NoDataProvidedException() noexcept;
virtual ~NoDataProvidedException() noexcept;
virtual const char *what() const noexcept;
};
class TAG_PARSER_EXPORT TruncatedDataException : public InvalidDataException {
public:
TruncatedDataException() noexcept;
virtual ~TruncatedDataException() noexcept;
virtual const char *what() const noexcept;
};
class TAG_PARSER_EXPORT OperationAbortedException : public Failure {
public:
OperationAbortedException() noexcept;
virtual ~OperationAbortedException() noexcept;
virtual const char *what() const noexcept;
};
class TAG_PARSER_EXPORT VersionNotSupportedException : public Failure {
public:
VersionNotSupportedException() noexcept;
virtual ~VersionNotSupportedException() noexcept;
virtual const char *what() const noexcept;
};
class TAG_PARSER_EXPORT NotImplementedException : public Failure {
public:
NotImplementedException() noexcept;
virtual ~NotImplementedException() noexcept;
virtual const char *what() const noexcept;
};
/*!
* \brief Throws TruncatedDataException() if the specified \a sizeDenotation exceeds maxSize; otherwise maxSize is reduced by \a sizeDenotation.
*/
#define CHECK_MAX_SIZE(sizeDenotation) \
if (maxSize < sizeDenotation) { \
throw TruncatedDataException(); \
} else { \
maxSize -= sizeDenotation; \
}
} // namespace TagParser
#endif // TAG_PARSER_EXCEPTIONS_H