Sayonara Player
Loading...
Searching...
No Matches
LyricServer.h
1/* LyricServer.h */
2
3/* Copyright (C) 2012 Michael Lugmair (Lucio Carreras)
4 *
5 * This file is part of sayonara player
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef LYRICSERVER_H_
22#define LYRICSERVER_H_
23
24#include <QString>
25#include <QList>
26#include <QPair>
27#include <QMap>
28#include "Utils/Pimpl.h"
29
30class QJsonObject;
31
32namespace Lyrics
33{
34 class Server
35 {
36 PIMPL(Server)
37
38 public:
39 Server();
40 ~Server();
41
42 using StartEndTag = QPair<QString, QString>;
43 using StartEndTags = QList<StartEndTag>;
44 using Replacement = QPair<QString, QString>;
45 using Replacements = QList<Replacement>;
46
47 [[nodiscard]] bool canFetchDirectly() const;
48 [[nodiscard]] bool canSearch() const;
49
50 [[nodiscard]] QString name() const;
51 void setName(const QString& name);
52
53 [[nodiscard]] QString address() const;
54 void setAddress(const QString& address);
55
56 [[nodiscard]] Replacements replacements() const;
57 void setReplacements(const Replacements& replacements);
58
59 [[nodiscard]] QString directUrlTemplate() const;
60 void setDirectUrlTemplate(const QString& directUrlTemplate);
61
62 [[nodiscard]] StartEndTags startEndTag() const;
63 void setStartEndTag(const StartEndTags& startEndTag);
64
65 [[nodiscard]] bool isStartTagIncluded() const;
66 void setIsStartTagIncluded(bool isStartTagIncluded);
67
68 [[nodiscard]] bool isEndTagIncluded() const;
69 void setIsEndTagIncluded(bool isEndTagIncluded);
70
71 [[nodiscard]] bool isNumeric() const;
72 void setIsNumeric(bool isNumeric);
73
74 [[nodiscard]] bool isLowercase() const;
75 void setIsLowercase(bool isLowercase);
76
77 [[nodiscard]] QString errorString() const;
78 void setErrorString(const QString& errorString);
79
80 [[nodiscard]] QString searchResultRegex() const;
81 void setSearchResultRegex(const QString& searchResultRegex);
82
83 [[nodiscard]] QString searchResultUrlTemplate() const;
84 void setSearchResultUrlTemplate(const QString& searchResultUrlTemplate);
85
86 [[nodiscard]] QString searchUrlTemplate() const;
87 void setSearchUrlTemplate(const QString& searchUrlTemplate);
88
89 QJsonObject toJson();
90 static ::Lyrics::Server* fromJson(const QJsonObject& json);
91
92 static QString applyReplacements(const QString& str, const Server::Replacements& replacements);
93
94 private:
95 [[nodiscard]] QString applyReplacements(const QString& str) const;
96 };
97}
98
99#endif /* LYRICSERVER_H_ */
Definition EngineUtils.h:33
Definition typedefs.h:33