strawberry-audio-player-win.../3rdparty/taglib/dsdiff/dsdiffdiintag.cpp

148 lines
4.1 KiB
C++
Raw Normal View History

2018-09-02 01:39:02 +02:00
/***************************************************************************
copyright : (C) 2016 by Damien Plisson, Audirvana
email : damien78@audirvana.com
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include "dsdiffdiintag.h"
#include "tstringlist.h"
#include "tpropertymap.h"
2020-06-26 23:30:30 +02:00
#include "tpicturemap.h"
2018-09-02 01:39:02 +02:00
using namespace Strawberry_TagLib::TagLib;
2018-09-02 01:39:02 +02:00
using namespace DSDIFF::DIIN;
2020-06-13 19:02:42 +02:00
class DSDIFF::DIIN::Tag::TagPrivate {
public:
TagPrivate() {
2018-09-02 01:39:02 +02:00
}
String title;
String artist;
};
2020-06-15 00:11:52 +02:00
DSDIFF::DIIN::Tag::Tag() {
2018-09-02 01:39:02 +02:00
d = new TagPrivate;
}
2020-06-13 19:02:42 +02:00
DSDIFF::DIIN::Tag::~Tag() {
2018-09-02 01:39:02 +02:00
delete d;
}
2020-06-13 19:02:42 +02:00
String DSDIFF::DIIN::Tag::title() const {
2018-09-02 01:39:02 +02:00
return d->title;
}
2020-06-13 19:02:42 +02:00
String DSDIFF::DIIN::Tag::artist() const {
2018-09-02 01:39:02 +02:00
return d->artist;
}
2020-06-13 19:02:42 +02:00
String DSDIFF::DIIN::Tag::album() const {
2018-09-02 01:39:02 +02:00
return String();
}
2020-06-13 19:02:42 +02:00
String DSDIFF::DIIN::Tag::comment() const {
2018-09-02 01:39:02 +02:00
return String();
}
2020-06-13 19:02:42 +02:00
String DSDIFF::DIIN::Tag::genre() const {
2018-09-02 01:39:02 +02:00
return String();
}
2020-06-13 19:02:42 +02:00
unsigned int DSDIFF::DIIN::Tag::year() const {
2018-09-02 01:39:02 +02:00
return 0;
}
2020-06-13 19:02:42 +02:00
unsigned int DSDIFF::DIIN::Tag::track() const {
2018-09-02 01:39:02 +02:00
return 0;
}
2020-06-26 23:30:30 +02:00
PictureMap DSDIFF::DIIN::Tag::pictures() const {
return PictureMap();
}
2020-06-13 19:02:42 +02:00
void DSDIFF::DIIN::Tag::setTitle(const String &title) {
2020-06-26 23:30:30 +02:00
d->title = title;
2018-09-02 01:39:02 +02:00
}
2020-06-13 19:02:42 +02:00
void DSDIFF::DIIN::Tag::setArtist(const String &artist) {
2020-06-26 23:30:30 +02:00
d->artist = artist;
2018-09-02 01:39:02 +02:00
}
void DSDIFF::DIIN::Tag::setAlbum(const String &) {}
2018-09-02 01:39:02 +02:00
void DSDIFF::DIIN::Tag::setComment(const String &) {}
2018-09-02 01:39:02 +02:00
void DSDIFF::DIIN::Tag::setGenre(const String &) {}
2018-09-02 01:39:02 +02:00
void DSDIFF::DIIN::Tag::setYear(unsigned int) {}
void DSDIFF::DIIN::Tag::setTrack(unsigned int) {}
2018-09-02 01:39:02 +02:00
2020-06-26 23:30:30 +02:00
void DSDIFF::DIIN::Tag::setPictures(const PictureMap&) {}
2020-06-13 19:02:42 +02:00
PropertyMap DSDIFF::DIIN::Tag::properties() const {
2018-09-02 01:39:02 +02:00
PropertyMap properties;
properties["TITLE"] = d->title;
properties["ARTIST"] = d->artist;
return properties;
2018-09-02 01:39:02 +02:00
}
2020-06-13 19:02:42 +02:00
PropertyMap DSDIFF::DIIN::Tag::setProperties(const PropertyMap &origProps) {
2018-09-02 01:39:02 +02:00
PropertyMap properties(origProps);
properties.removeEmpty();
StringList oneValueSet;
2020-06-13 19:02:42 +02:00
if (properties.contains("TITLE")) {
2018-09-02 01:39:02 +02:00
d->title = properties["TITLE"].front();
oneValueSet.append("TITLE");
2020-06-13 19:02:42 +02:00
}
else
2018-09-02 01:39:02 +02:00
d->title = String();
2020-06-13 19:02:42 +02:00
if (properties.contains("ARTIST")) {
2018-09-02 01:39:02 +02:00
d->artist = properties["ARTIST"].front();
oneValueSet.append("ARTIST");
2020-06-13 19:02:42 +02:00
}
else
2018-09-02 01:39:02 +02:00
d->artist = String();
// for each tag that has been set above, remove the first entry in the corresponding
// value list. The others will be returned as unsupported by this format.
2020-06-13 19:02:42 +02:00
for (StringList::Iterator it = oneValueSet.begin(); it != oneValueSet.end(); ++it) {
if (properties[*it].size() == 1)
2018-09-02 01:39:02 +02:00
properties.erase(*it);
else
properties[*it].erase(properties[*it].begin());
}
return properties;
2018-09-02 01:39:02 +02:00
}