File indexing completed on 2024-04-14 04:43:17

0001 /* AUDEX CDDA EXTRACTOR
0002  * SPDX-FileCopyrightText: Copyright (C) 2007 Marco Nelles
0003  * <https://userbase.kde.org/Audex>
0004  *
0005  * SPDX-License-Identifier: GPL-3.0-or-later
0006  */
0007 
0008 #ifndef ERROR_H
0009 #define ERROR_H
0010 
0011 #include <QObject>
0012 #include <QString>
0013 
0014 class Error
0015 {
0016 public:
0017     enum ErrorType { ERROR, WARNING };
0018 
0019     explicit Error(const QString &message = "", const QString &details = "", const ErrorType errorType = Error::ERROR, QObject *parent = nullptr)
0020     {
0021         Q_UNUSED(parent);
0022         p_message = message;
0023         p_details = details;
0024         p_type = errorType;
0025     }
0026     Error(const Error &other)
0027     {
0028         p_message = other.p_message;
0029         p_details = other.p_details;
0030         p_type = other.p_type;
0031     }
0032     Error &operator=(const Error &other)
0033     {
0034         p_message = other.p_message;
0035         p_details = other.p_details;
0036         p_type = other.p_type;
0037         return *this;
0038     }
0039     ~Error()
0040     {
0041     }
0042 
0043     void clear()
0044     {
0045         p_type = Error::ERROR;
0046         p_message.clear();
0047         p_details.clear();
0048     }
0049 
0050     bool operator==(const Error &other) const
0051     {
0052         return p_message == other.p_message && p_details == other.p_details && p_type == other.p_type;
0053     }
0054 
0055     bool operator!=(const Error &other) const
0056     {
0057         return p_message != other.p_message || p_details != other.p_details || p_type != other.p_type;
0058     }
0059 
0060     ErrorType errorType() const
0061     {
0062         return p_type;
0063     }
0064 
0065     bool isValid() const
0066     {
0067         return (!p_message.isEmpty());
0068     }
0069 
0070     const QString message() const
0071     {
0072         return p_message;
0073     }
0074     const QString details() const
0075     {
0076         return p_details;
0077     }
0078 
0079 private:
0080     ErrorType p_type;
0081     QString p_message;
0082     QString p_details;
0083 };
0084 
0085 typedef QList<Error> ErrorList;
0086 
0087 #endif