libquentier  0.8.0
The library for rich desktop clients of Evernote service
IConverter.h
1 /*
2  * Copyright 2023-2024 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/enml/Fwd.h>
22 #include <quentier/enml/conversion_rules/Fwd.h>
23 #include <quentier/types/ErrorString.h>
24 #include <quentier/types/Result.h>
25 #include <quentier/utility/Linkage.h>
26 
27 #include <QList>
28 #include <QStringList>
29 #include <QTextDocument>
30 
31 #include <qevercloud/types/Note.h>
32 
33 namespace quentier::enml {
34 
39 class QUENTIER_EXPORT IConverter
40 {
41 public:
42  virtual ~IConverter();
43 
52  [[nodiscard]] virtual Result<QString, ErrorString> convertHtmlToEnml(
53  const QString & html, IDecryptedTextCache & decryptedTextCache,
54  const QList<conversion_rules::ISkipRulePtr> & skipRules = {}) const = 0;
55 
64  [[nodiscard]] virtual Result<void, ErrorString> convertHtmlToDoc(
65  const QString & html, QTextDocument & doc,
66  const QList<conversion_rules::ISkipRulePtr> & skipRules = {}) const = 0;
67 
74  [[nodiscard]] virtual Result<QString, ErrorString> convertHtmlToXml(
75  const QString & html) const = 0;
76 
83  [[nodiscard]] virtual Result<QString, ErrorString> convertHtmlToXhtml(
84  const QString & html) const = 0;
85 
93  [[nodiscard]] virtual Result<IHtmlDataPtr, ErrorString> convertEnmlToHtml(
94  const QString & enml,
95  IDecryptedTextCache & decryptedTextCache) const = 0;
96 
103  [[nodiscard]] virtual Result<QString, ErrorString> convertEnmlToPlainText(
104  const QString & enml) const = 0;
105 
112  [[nodiscard]] virtual Result<QStringList, ErrorString>
113  convertEnmlToWordsList(const QString & enml) const = 0;
114 
120  [[nodiscard]] virtual QStringList convertPlainTextToWordsList(
121  const QString & plainText) const = 0;
122 
129  [[nodiscard]] virtual Result<void, ErrorString> validateEnml(
130  const QString & enml) const = 0;
131 
138  [[nodiscard]] virtual Result<QString, ErrorString> validateAndFixupEnml(
139  const QString & enml) const = 0;
140 
145  enum class EnexExportTags
146  {
147  Yes = 0,
148  No
149  };
150 
160  [[nodiscard]] virtual Result<QString, ErrorString> exportNotesToEnex(
161  const QList<qevercloud::Note> & notes,
162  const QHash<QString, QString> & tagNamesByTagLocalIds,
163  EnexExportTags exportTagsOption,
164  const QString & version = {}) const = 0;
165 
174  [[nodiscard]] virtual Result<QList<qevercloud::Note>, ErrorString>
175  importEnex(const QString & enex) const = 0;
176 };
177 
178 } // namespace quentier::enml
Definition: IDecryptedTextCache.h:34
The ErrorString class encapsulates two (or more) strings which are meant to contain translatable (bas...
Definition: ErrorString.h:42
The IConverter interface encapsulates a set of methods performing conversions between ENML and other ...
Definition: IConverter.h:39
Definition: Result.h:33
EnexExportTags
The EnexExportTags enum allows to specify whether export of note(s) to ENEX should include the names ...
Definition: IConverter.h:145