Sayonara Player
Loading...
Searching...
No Matches
TaggingExtraFields.h
1/* ${CLASS_NAME}.h */
2/*
3 * Copyright (C) 2011-2024 Michael Lugmair
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#ifndef SAYONARA_PLAYER_TAGGINGEXTRAFIELDS_H
21#define SAYONARA_PLAYER_TAGGINGEXTRAFIELDS_H
22
23class MetaData;
24class QString;
25
26#include "typedefs.h"
27#include <optional>
28
29namespace Models
30{
31 struct Discnumber;
32 struct Popularimeter;
33}
34
35namespace Tagging
36{
37 template<typename FrameType, typename Model, typename Tag>
38 std::optional<Model> tryToRead(Tag* tag)
39 {
40 if(tag)
41 {
42 Model model;
43 auto frame = FrameType(tag);
44 const auto success = frame.read(model);
45 if(success)
46 {
47 return model;
48 }
49 }
50
51 return std::nullopt;
52 }
53
54 template<typename FrameType, typename Tag, typename Model>
55 void tryToWrite(Tag* tag, const Model& model)
56 {
57 if(tag)
58 {
59 FrameType frame(tag);
60 frame.write(model);
61 }
62 }
63
64 struct ParsedTag;
65
66 std::optional<Models::Discnumber> readDiscnumber(const Tagging::ParsedTag& parsedTag);
67 void writeDiscnumber(const Tagging::ParsedTag& parsedTag, const Models::Discnumber& discnumber);
68
69 std::optional<Models::Popularimeter> readPopularimeter(const Tagging::ParsedTag& parsedTag);
70 void writePopularimeter(const Tagging::ParsedTag& parsedTag, const Models::Popularimeter& popularimeter);
71
72 std::optional<QString> readAlbumArtist(const Tagging::ParsedTag& parsedTag);
73 void writeAlbumArtist(const Tagging::ParsedTag& parsedTag, const QString& albumArtist);
74}
75
76#endif //SAYONARA_PLAYER_TAGGINGEXTRAFIELDS_H
Definition MetaData.h:43
The GUI_TagEdit class.
Definition Engine.h:33
Definition Discnumber.h:31
Definition Popularimeter.h:31
Definition TaggingUtils.h:60