tagparser/exceptions.h

73 lines
2.6 KiB
C
Raw 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:
Failure() USE_NOTHROW;
virtual ~Failure() USE_NOTHROW;
virtual const char *what() const USE_NOTHROW;
};
2018-03-07 01:17:50 +01:00
class TAG_PARSER_EXPORT NoDataFoundException : public Failure {
2015-04-22 19:22:01 +02:00
public:
NoDataFoundException() USE_NOTHROW;
virtual ~NoDataFoundException() USE_NOTHROW;
virtual const char *what() const USE_NOTHROW;
};
2018-03-07 01:17:50 +01:00
class TAG_PARSER_EXPORT InvalidDataException : public Failure {
2015-04-22 19:22:01 +02:00
public:
InvalidDataException() USE_NOTHROW;
virtual ~InvalidDataException() USE_NOTHROW;
virtual const char *what() const USE_NOTHROW;
};
2018-03-07 01:17:50 +01:00
class TAG_PARSER_EXPORT TruncatedDataException : public InvalidDataException {
2015-04-22 19:22:01 +02:00
public:
TruncatedDataException() USE_NOTHROW;
virtual ~TruncatedDataException() USE_NOTHROW;
virtual const char *what() const USE_NOTHROW;
};
2018-03-07 01:17:50 +01:00
class TAG_PARSER_EXPORT OperationAbortedException : public Failure {
2015-04-22 19:22:01 +02:00
public:
OperationAbortedException() USE_NOTHROW;
virtual ~OperationAbortedException() USE_NOTHROW;
virtual const char *what() const USE_NOTHROW;
};
2018-03-07 01:17:50 +01:00
class TAG_PARSER_EXPORT VersionNotSupportedException : public Failure {
2015-04-22 19:22:01 +02:00
public:
VersionNotSupportedException() USE_NOTHROW;
virtual ~VersionNotSupportedException() USE_NOTHROW;
virtual const char *what() const USE_NOTHROW;
};
2018-03-07 01:17:50 +01:00
class TAG_PARSER_EXPORT NotImplementedException : public Failure {
2015-04-22 19:22:01 +02:00
public:
NotImplementedException() USE_NOTHROW;
virtual ~NotImplementedException() USE_NOTHROW;
virtual const char *what() const USE_NOTHROW;
};
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