File indexing completed on 2024-04-21 04:32:07

0001 /*
0002  * Copyright (C) 2011-2015 by Stephen Allewell
0003  * steve.allewell@gmail.com
0004  *
0005  * This program is free software; you can redistribute it and/or modify
0006  * it under the terms of the GNU General Public License as published by
0007  * the Free Software Foundation; either version 2 of the License, or
0008  * (at your option) any later version.
0009  */
0010 
0011 /**
0012  * @file
0013  * Header file for the exception classes.
0014  */
0015 
0016 #ifndef Exceptions_H
0017 #define Exceptions_H
0018 
0019 #include <QDataStream>
0020 #include <QtGlobal>
0021 
0022 /**
0023  * @brief Invalid file exception class.
0024  *
0025  * This is thrown when the file being opened is not a supported cross
0026  * stitch file type or symbol library.
0027  */
0028 class InvalidFile
0029 {
0030 public:
0031     InvalidFile();
0032 
0033 private:
0034 };
0035 
0036 /**
0037  * @brief Invalid file version exception class.
0038  *
0039  * This is thrown when the file being opened is not a supported version
0040  * of a cross stitch or library file or one of the elements is an
0041  * unsupported version.
0042  */
0043 class InvalidFileVersion
0044 {
0045 public:
0046     explicit InvalidFileVersion(const QString &v);
0047 
0048     QString version; /**< the version of the file read */
0049 };
0050 
0051 /**
0052  * @brief Failed to read the file exception class.
0053  *
0054  * This is thrown when there was an error reading the QDataStream.
0055  */
0056 class FailedReadFile
0057 {
0058 public:
0059     explicit FailedReadFile(QDataStream::Status s);
0060     explicit FailedReadFile(const QString &s);
0061 
0062     QString status; /**< the status of the error */
0063 };
0064 
0065 /**
0066  * @brief Failed to write the file exception class.
0067  *
0068  * This is thrown when there was an error writing to the QDataStream.
0069  */
0070 class FailedWriteFile
0071 {
0072 public:
0073     explicit FailedWriteFile(QDataStream::Status status);
0074 
0075     QString statusMessage() const;
0076 
0077 private:
0078     QDataStream::Status m_status; /**< the status of the error */
0079 };
0080 
0081 /**
0082  * @brief Found an invalid symbol version.
0083  *
0084  * This is thrown when the symbol being read was not a known version.
0085  */
0086 class InvalidSymbolVersion
0087 {
0088 public:
0089     explicit InvalidSymbolVersion(qint32 v);
0090 
0091     qint32 version; /** the version of the symbol read */
0092 };
0093 
0094 #endif