Sayonara Player
AbstractFrame.h
1 /* AbstractFrame.h */
2 
3 /* Copyright (C) 2011-2017 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 
22 
23 #ifndef TAGGINGABSTRACTFRAME_H
24 #define TAGGINGABSTRACTFRAME_H
25 
26 #include "Helper/Pimpl.h"
27 
28 #include <QString>
29 
30 class QString;
31 namespace TagLib
32 {
33  class Tag;
34  class String;
35 }
36 
37 
38 namespace Tagging
39 {
41  {
42  public:
43  explicit AbstractFrameHelper(const QString& key=QString());
44  virtual ~AbstractFrameHelper();
45 
46  protected:
47  QString cvt_string(const TagLib::String str) const;
48  TagLib::String cvt_string(const QString& str) const;
49  QString key() const;
50  TagLib::String tag_key() const;
51 
52  private:
53  PIMPL(AbstractFrameHelper)
54  };
55 
56  template<typename TagImpl>
57  class AbstractFrame :
58  public AbstractFrameHelper
59  {
60  private:
61  TagImpl* _tag=nullptr;
62 
63  protected:
64  AbstractFrame(TagLib::Tag* tag, const QString& key=QString()) :
66  {
67  _tag = dynamic_cast<TagImpl*>(tag);
68  }
69 
70  TagImpl* tag() const
71  {
72  return _tag;
73  }
74 
75  void set_tag(TagImpl* tag)
76  {
77  _tag = tag;
78  }
79  };
80 }
81 #endif // TAGGINGABSTRACTFRAME_H
Definition: AbstractFrame.h:40
Tagging namespace.
Definition: AbstractFrame.h:38
Definition: AbstractFrame.h:31
Definition: AbstractFrame.h:57