21 #ifndef ID3V2_FRAME_H_ 22 #define ID3V2_FRAME_H_ 24 #include "Utils/Tagging/AbstractFrame.h" 26 #include <taglib/fileref.h> 27 #include <taglib/mpegfile.h> 28 #include <taglib/id3v2tag.h> 29 #include <taglib/id3v2frame.h> 39 template<
typename ModelType_t,
typename FrameType_t>
50 FrameType_t* _frame=
nullptr;
68 virtual void map_frame_to_model(
const FrameType_t* frame, ModelType_t& model)=0;
73 ID3v2Frame(
const TagLib::FileRef& f,
const char* four) :
76 TagLib::MPEG::File* mpeg = dynamic_cast<TagLib::MPEG::File*>(f.file());
81 TagLib::ID3v2::Tag* tag = mpeg->ID3v2Tag(
true);
88 TagLib::ByteVector vec(four, 4);
89 TagLib::ID3v2::FrameListMap map = tag->frameListMap();
90 TagLib::ID3v2::FrameList frame_list = map[vec];
91 if(!frame_list.isEmpty()) {
92 _frame = dynamic_cast<FrameType_t*> (frame_list.front());
106 virtual bool read(ModelType_t& data)
112 map_frame_to_model(_frame, data);
124 virtual bool write(
const ModelType_t& data_model)
126 bool created =
false;
128 TagLib::ID3v2::Tag* tag = this->tag();
146 tag->addFrame(_frame);
159 return (_frame !=
nullptr);
164 #endif // ABSTRACTFRAME_H virtual void map_model_to_frame(const ModelType_t &model, FrameType_t *frame)=0
map_model_to_frame maps the model to the frame and vice versa so the frame knows how to get/set data
virtual bool read(ModelType_t &data)
sets the _data_model by reading from the frame
Definition: ID3v2Frame.h:106
ID3v2Frame namespace.
Definition: AlbumArtist.h:26
virtual TagLib::ID3v2::Frame * create_id3v2_frame()=0
create_id3v2_frame creates new id3v2 frame if there's no frame we have to create it manually every su...
The AbstractFrame class for example AbstractFrame<Discnumber, TagLib::ID3v2::TextIdentificationFrame>
Definition: ID3v2Frame.h:46
bool is_frame_found() const
if the frame was found when called read()
Definition: ID3v2Frame.h:157
virtual bool write(const ModelType_t &data_model)
insert the _data_model into the frame
Definition: ID3v2Frame.h:124
Definition: AbstractFrame.h:57