libquentier  0.8.0
The library for rich desktop clients of Evernote service
ErrorString.h
1 /*
2  * Copyright 2017-2025 Dmitry Ivanov
3  *
4  * This file is part of libquentier
5  *
6  * libquentier is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, version 3 of the License.
9  *
10  * libquentier is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with libquentier. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #pragma once
20 
21 #include <quentier/utility/Printable.h>
22 
23 #include <QSharedDataPointer>
24 
25 namespace quentier {
26 
27 class ErrorStringData;
28 
42 class QUENTIER_EXPORT ErrorString : public utility::Printable
43 {
44 public:
45  explicit ErrorString(const char * error = nullptr);
46  explicit ErrorString(const QString & error);
47 
48  ErrorString(const ErrorString & other);
49  ErrorString(ErrorString && other) noexcept;
50 
51  ErrorString & operator=(const ErrorString & other);
52  ErrorString & operator=(ErrorString && other) noexcept;
53 
54  ~ErrorString() override;
55 
56  [[nodiscard]] const QString & base() const noexcept;
57  [[nodiscard]] QString & base();
58 
59  [[nodiscard]] const QStringList & additionalBases() const noexcept;
60  [[nodiscard]] QStringList & additionalBases();
61 
62  [[nodiscard]] const QString & details() const noexcept;
63  [[nodiscard]] QString & details();
64 
65  void setBase(QString error);
66  void setBase(const char * error);
67 
68  void appendBase(const QString & error);
69  void appendBase(const QStringList & errors);
70  void appendBase(const char * error);
71 
72  void setDetails(const QString & error);
73  void setDetails(const char * error);
74 
75  [[nodiscard]] bool isEmpty() const;
76  void clear();
77 
78  [[nodiscard]] QString localizedString() const;
79  [[nodiscard]] QString nonLocalizedString() const;
80 
81  QTextStream & print(QTextStream & strm) const override;
82 
83 private:
84  QSharedDataPointer<ErrorStringData> d;
85 };
86 
87 [[nodiscard]] QUENTIER_EXPORT bool operator==(
88  const ErrorString & lhs, const ErrorString & rhs) noexcept;
89 
90 [[nodiscard]] QUENTIER_EXPORT bool operator!=(
91  const ErrorString & lhs, const ErrorString & rhs) noexcept;
92 
93 } // namespace quentier
The ErrorString class encapsulates two (or more) strings which are meant to contain translatable (bas...
Definition: ErrorString.h:42
The Printable class is the interface for Quentier&#39;s internal classes which should be able to write th...
Definition: Printable.h:37