Format taglib sources
This commit is contained in:
158
3rdparty/taglib/tagunion.cpp
vendored
158
3rdparty/taglib/tagunion.cpp
vendored
@@ -35,42 +35,38 @@
|
||||
|
||||
using namespace Strawberry_TagLib::TagLib;
|
||||
|
||||
#define stringUnion(method) \
|
||||
if(tag(0) && !tag(0)->method().isEmpty()) \
|
||||
return tag(0)->method(); \
|
||||
if(tag(1) && !tag(1)->method().isEmpty()) \
|
||||
return tag(1)->method(); \
|
||||
if(tag(2) && !tag(2)->method().isEmpty()) \
|
||||
return tag(2)->method(); \
|
||||
return String(); \
|
||||
#define stringUnion(method) \
|
||||
if (tag(0) && !tag(0)->method().isEmpty()) \
|
||||
return tag(0)->method(); \
|
||||
if (tag(1) && !tag(1)->method().isEmpty()) \
|
||||
return tag(1)->method(); \
|
||||
if (tag(2) && !tag(2)->method().isEmpty()) \
|
||||
return tag(2)->method(); \
|
||||
return String();
|
||||
|
||||
#define numberUnion(method) \
|
||||
if(tag(0) && tag(0)->method() > 0) \
|
||||
return tag(0)->method(); \
|
||||
if(tag(1) && tag(1)->method() > 0) \
|
||||
return tag(1)->method(); \
|
||||
if(tag(2) && tag(2)->method() > 0) \
|
||||
return tag(2)->method(); \
|
||||
#define numberUnion(method) \
|
||||
if (tag(0) && tag(0)->method() > 0) \
|
||||
return tag(0)->method(); \
|
||||
if (tag(1) && tag(1)->method() > 0) \
|
||||
return tag(1)->method(); \
|
||||
if (tag(2) && tag(2)->method() > 0) \
|
||||
return tag(2)->method(); \
|
||||
return 0
|
||||
|
||||
#define setUnion(method, value) \
|
||||
if(tag(0)) \
|
||||
tag(0)->set##method(value); \
|
||||
if(tag(1)) \
|
||||
tag(1)->set##method(value); \
|
||||
if(tag(2)) \
|
||||
tag(2)->set##method(value); \
|
||||
|
||||
class TagUnion::TagUnionPrivate
|
||||
{
|
||||
public:
|
||||
TagUnionPrivate() : tags(3, static_cast<Tag *>(0))
|
||||
{
|
||||
#define setUnion(method, value) \
|
||||
if (tag(0)) \
|
||||
tag(0)->set##method(value); \
|
||||
if (tag(1)) \
|
||||
tag(1)->set##method(value); \
|
||||
if (tag(2)) \
|
||||
tag(2)->set##method(value);
|
||||
|
||||
class TagUnion::TagUnionPrivate {
|
||||
public:
|
||||
TagUnionPrivate() : tags(3, static_cast<Tag *>(0)) {
|
||||
}
|
||||
|
||||
~TagUnionPrivate()
|
||||
{
|
||||
~TagUnionPrivate() {
|
||||
delete tags[0];
|
||||
delete tags[1];
|
||||
delete tags[2];
|
||||
@@ -79,57 +75,50 @@ public:
|
||||
std::vector<Tag *> tags;
|
||||
};
|
||||
|
||||
TagUnion::TagUnion(Tag *first, Tag *second, Tag *third) :
|
||||
d(new TagUnionPrivate())
|
||||
{
|
||||
TagUnion::TagUnion(Tag *first, Tag *second, Tag *third) : d(new TagUnionPrivate()) {
|
||||
d->tags[0] = first;
|
||||
d->tags[1] = second;
|
||||
d->tags[2] = third;
|
||||
}
|
||||
|
||||
TagUnion::~TagUnion()
|
||||
{
|
||||
TagUnion::~TagUnion() {
|
||||
delete d;
|
||||
}
|
||||
|
||||
Tag *TagUnion::operator[](int index) const
|
||||
{
|
||||
Tag *TagUnion::operator[](int index) const {
|
||||
return tag(index);
|
||||
}
|
||||
|
||||
Tag *TagUnion::tag(int index) const
|
||||
{
|
||||
Tag *TagUnion::tag(int index) const {
|
||||
return d->tags[index];
|
||||
}
|
||||
|
||||
void TagUnion::set(int index, Tag *tag)
|
||||
{
|
||||
void TagUnion::set(int index, Tag *tag) {
|
||||
delete d->tags[index];
|
||||
d->tags[index] = tag;
|
||||
}
|
||||
|
||||
PropertyMap TagUnion::properties() const
|
||||
{
|
||||
PropertyMap TagUnion::properties() const {
|
||||
// This is an ugly workaround but we can't add a virtual function.
|
||||
// Should be virtual in taglib2.
|
||||
|
||||
for(size_t i = 0; i < 3; ++i) {
|
||||
for (size_t i = 0; i < 3; ++i) {
|
||||
|
||||
if(d->tags[i] && !d->tags[i]->isEmpty()) {
|
||||
if (d->tags[i] && !d->tags[i]->isEmpty()) {
|
||||
|
||||
if(dynamic_cast<const ID3v1::Tag *>(d->tags[i]))
|
||||
if (dynamic_cast<const ID3v1::Tag *>(d->tags[i]))
|
||||
return dynamic_cast<const ID3v1::Tag *>(d->tags[i])->properties();
|
||||
|
||||
else if(dynamic_cast<const ID3v2::Tag *>(d->tags[i]))
|
||||
else if (dynamic_cast<const ID3v2::Tag *>(d->tags[i]))
|
||||
return dynamic_cast<const ID3v2::Tag *>(d->tags[i])->properties();
|
||||
|
||||
else if(dynamic_cast<const APE::Tag *>(d->tags[i]))
|
||||
else if (dynamic_cast<const APE::Tag *>(d->tags[i]))
|
||||
return dynamic_cast<const APE::Tag *>(d->tags[i])->properties();
|
||||
|
||||
else if(dynamic_cast<const Ogg::XiphComment *>(d->tags[i]))
|
||||
else if (dynamic_cast<const Ogg::XiphComment *>(d->tags[i]))
|
||||
return dynamic_cast<const Ogg::XiphComment *>(d->tags[i])->properties();
|
||||
|
||||
else if(dynamic_cast<const RIFF::Info::Tag *>(d->tags[i]))
|
||||
else if (dynamic_cast<const RIFF::Info::Tag *>(d->tags[i]))
|
||||
return dynamic_cast<const RIFF::Info::Tag *>(d->tags[i])->properties();
|
||||
}
|
||||
}
|
||||
@@ -137,112 +126,95 @@ PropertyMap TagUnion::properties() const
|
||||
return PropertyMap();
|
||||
}
|
||||
|
||||
void TagUnion::removeUnsupportedProperties(const StringList &unsupported)
|
||||
{
|
||||
void TagUnion::removeUnsupportedProperties(const StringList &unsupported) {
|
||||
// This is an ugly workaround but we can't add a virtual function.
|
||||
// Should be virtual in taglib2.
|
||||
|
||||
for(size_t i = 0; i < 3; ++i) {
|
||||
for (size_t i = 0; i < 3; ++i) {
|
||||
|
||||
if(d->tags[i]) {
|
||||
if (d->tags[i]) {
|
||||
|
||||
if(dynamic_cast<ID3v1::Tag *>(d->tags[i]))
|
||||
if (dynamic_cast<ID3v1::Tag *>(d->tags[i]))
|
||||
dynamic_cast<ID3v1::Tag *>(d->tags[i])->removeUnsupportedProperties(unsupported);
|
||||
|
||||
else if(dynamic_cast<ID3v2::Tag *>(d->tags[i]))
|
||||
else if (dynamic_cast<ID3v2::Tag *>(d->tags[i]))
|
||||
dynamic_cast<ID3v2::Tag *>(d->tags[i])->removeUnsupportedProperties(unsupported);
|
||||
|
||||
else if(dynamic_cast<APE::Tag *>(d->tags[i]))
|
||||
else if (dynamic_cast<APE::Tag *>(d->tags[i]))
|
||||
dynamic_cast<APE::Tag *>(d->tags[i])->removeUnsupportedProperties(unsupported);
|
||||
|
||||
else if(dynamic_cast<Ogg::XiphComment *>(d->tags[i]))
|
||||
else if (dynamic_cast<Ogg::XiphComment *>(d->tags[i]))
|
||||
dynamic_cast<Ogg::XiphComment *>(d->tags[i])->removeUnsupportedProperties(unsupported);
|
||||
|
||||
else if(dynamic_cast<RIFF::Info::Tag *>(d->tags[i]))
|
||||
else if (dynamic_cast<RIFF::Info::Tag *>(d->tags[i]))
|
||||
dynamic_cast<RIFF::Info::Tag *>(d->tags[i])->removeUnsupportedProperties(unsupported);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String TagUnion::title() const
|
||||
{
|
||||
String TagUnion::title() const {
|
||||
stringUnion(title);
|
||||
}
|
||||
|
||||
String TagUnion::artist() const
|
||||
{
|
||||
String TagUnion::artist() const {
|
||||
stringUnion(artist);
|
||||
}
|
||||
|
||||
String TagUnion::album() const
|
||||
{
|
||||
String TagUnion::album() const {
|
||||
stringUnion(album);
|
||||
}
|
||||
|
||||
String TagUnion::comment() const
|
||||
{
|
||||
String TagUnion::comment() const {
|
||||
stringUnion(comment);
|
||||
}
|
||||
|
||||
String TagUnion::genre() const
|
||||
{
|
||||
String TagUnion::genre() const {
|
||||
stringUnion(genre);
|
||||
}
|
||||
|
||||
unsigned int TagUnion::year() const
|
||||
{
|
||||
unsigned int TagUnion::year() const {
|
||||
numberUnion(year);
|
||||
}
|
||||
|
||||
unsigned int TagUnion::track() const
|
||||
{
|
||||
unsigned int TagUnion::track() const {
|
||||
numberUnion(track);
|
||||
}
|
||||
|
||||
void TagUnion::setTitle(const String &s)
|
||||
{
|
||||
void TagUnion::setTitle(const String &s) {
|
||||
setUnion(Title, s);
|
||||
}
|
||||
|
||||
void TagUnion::setArtist(const String &s)
|
||||
{
|
||||
void TagUnion::setArtist(const String &s) {
|
||||
setUnion(Artist, s);
|
||||
}
|
||||
|
||||
void TagUnion::setAlbum(const String &s)
|
||||
{
|
||||
void TagUnion::setAlbum(const String &s) {
|
||||
setUnion(Album, s);
|
||||
}
|
||||
|
||||
void TagUnion::setComment(const String &s)
|
||||
{
|
||||
void TagUnion::setComment(const String &s) {
|
||||
setUnion(Comment, s);
|
||||
}
|
||||
|
||||
void TagUnion::setGenre(const String &s)
|
||||
{
|
||||
void TagUnion::setGenre(const String &s) {
|
||||
setUnion(Genre, s);
|
||||
}
|
||||
|
||||
void TagUnion::setYear(unsigned int i)
|
||||
{
|
||||
void TagUnion::setYear(unsigned int i) {
|
||||
setUnion(Year, i);
|
||||
}
|
||||
|
||||
void TagUnion::setTrack(unsigned int i)
|
||||
{
|
||||
void TagUnion::setTrack(unsigned int i) {
|
||||
setUnion(Track, i);
|
||||
}
|
||||
|
||||
bool TagUnion::isEmpty() const
|
||||
{
|
||||
if(d->tags[0] && !d->tags[0]->isEmpty())
|
||||
bool TagUnion::isEmpty() const {
|
||||
if (d->tags[0] && !d->tags[0]->isEmpty())
|
||||
return false;
|
||||
if(d->tags[1] && !d->tags[1]->isEmpty())
|
||||
if (d->tags[1] && !d->tags[1]->isEmpty())
|
||||
return false;
|
||||
if(d->tags[2] && !d->tags[2]->isEmpty())
|
||||
if (d->tags[2] && !d->tags[2]->isEmpty())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user