tagparser/exceptions.h

80 lines
2.8 KiB
C
Raw Permalink Normal View History

#ifndef TAG_PARSER_EXCEPTIONS_H
#define TAG_PARSER_EXCEPTIONS_H
2015-04-22 19:22:01 +02:00
2016-08-29 15:43:05 +02:00
#include "./global.h"
2015-04-22 19:22:01 +02:00
#include <stdexcept>
#include <string>
namespace TagParser {
2015-04-22 19:22:01 +02:00
2018-03-07 01:17:50 +01:00
class TAG_PARSER_EXPORT Failure : public std::exception {
2015-04-22 19:22:01 +02:00
public:
2019-02-17 17:14:07 +01:00
Failure() noexcept;
virtual ~Failure() noexcept;
virtual const char *what() const noexcept;
2015-04-22 19:22:01 +02:00
};
2018-03-07 01:17:50 +01:00
class TAG_PARSER_EXPORT NoDataFoundException : public Failure {
2015-04-22 19:22:01 +02:00
public:
2019-02-17 17:14:07 +01:00
NoDataFoundException() noexcept;
virtual ~NoDataFoundException() noexcept;
virtual const char *what() const noexcept;
2015-04-22 19:22:01 +02:00
};
2018-03-07 01:17:50 +01:00
class TAG_PARSER_EXPORT InvalidDataException : public Failure {
2015-04-22 19:22:01 +02:00
public:
2019-02-17 17:14:07 +01:00
InvalidDataException() noexcept;
virtual ~InvalidDataException() noexcept;
virtual const char *what() const noexcept;
2015-04-22 19:22:01 +02:00
};
class TAG_PARSER_EXPORT NoDataProvidedException : public Failure {
public:
2019-02-17 17:14:07 +01:00
NoDataProvidedException() noexcept;
virtual ~NoDataProvidedException() noexcept;
virtual const char *what() const noexcept;
};
2018-03-07 01:17:50 +01:00
class TAG_PARSER_EXPORT TruncatedDataException : public InvalidDataException {
2015-04-22 19:22:01 +02:00
public:
2019-02-17 17:14:07 +01:00
TruncatedDataException() noexcept;
virtual ~TruncatedDataException() noexcept;
virtual const char *what() const noexcept;
2015-04-22 19:22:01 +02:00
};
2018-03-07 01:17:50 +01:00
class TAG_PARSER_EXPORT OperationAbortedException : public Failure {
2015-04-22 19:22:01 +02:00
public:
2019-02-17 17:14:07 +01:00
OperationAbortedException() noexcept;
virtual ~OperationAbortedException() noexcept;
virtual const char *what() const noexcept;
2015-04-22 19:22:01 +02:00
};
2018-03-07 01:17:50 +01:00
class TAG_PARSER_EXPORT VersionNotSupportedException : public Failure {
2015-04-22 19:22:01 +02:00
public:
2019-02-17 17:14:07 +01:00
VersionNotSupportedException() noexcept;
virtual ~VersionNotSupportedException() noexcept;
virtual const char *what() const noexcept;
2015-04-22 19:22:01 +02:00
};
2018-03-07 01:17:50 +01:00
class TAG_PARSER_EXPORT NotImplementedException : public Failure {
2015-04-22 19:22:01 +02:00
public:
2019-02-17 17:14:07 +01:00
NotImplementedException() noexcept;
virtual ~NotImplementedException() noexcept;
virtual const char *what() const noexcept;
2015-04-22 19:22:01 +02:00
};
2016-05-16 20:56:53 +02:00
/*!
* \brief Throws TruncatedDataException() if the specified \a sizeDenotation exceeds maxSize; otherwise maxSize is reduced by \a sizeDenotation.
*/
2018-03-07 01:17:50 +01:00
#define CHECK_MAX_SIZE(sizeDenotation) \
if (maxSize < sizeDenotation) { \
throw TruncatedDataException(); \
} else { \
maxSize -= sizeDenotation; \
2016-05-16 20:56:53 +02:00
}
2018-03-07 01:17:50 +01:00
} // namespace TagParser
2015-04-22 19:22:01 +02:00
#endif // TAG_PARSER_EXCEPTIONS_H