Consistency with the rest of TagLib

git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@1214789 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
This commit is contained in:
Lukáš Lalinský 2011-01-16 12:00:52 +00:00
parent fb3cca2c44
commit 1352a4e0c3
3 changed files with 61 additions and 119 deletions

View File

@ -73,8 +73,7 @@ ASF::Attribute::Attribute(const ASF::Attribute &other)
d->ref();
}
ASF::Attribute &
ASF::Attribute::operator=(const ASF::Attribute &other)
ASF::Attribute &ASF::Attribute::operator=(const ASF::Attribute &other)
{
if(d->deref())
delete d;
@ -138,58 +137,49 @@ ASF::Attribute::Attribute(bool value)
d->boolValue = value;
}
ASF::Attribute::AttributeTypes
ASF::Attribute::type() const
ASF::Attribute::AttributeTypes ASF::Attribute::type() const
{
return d->type;
}
String
ASF::Attribute::toString() const
String ASF::Attribute::toString() const
{
return d->stringValue;
}
ByteVector
ASF::Attribute::toByteVector() const
ByteVector ASF::Attribute::toByteVector() const
{
if(d->pictureValue.isValid())
return d->pictureValue.render();
return d->byteVectorValue;
}
unsigned short
ASF::Attribute::toBool() const
unsigned short ASF::Attribute::toBool() const
{
return d->shortValue;
}
unsigned short
ASF::Attribute::toUShort() const
unsigned short ASF::Attribute::toUShort() const
{
return d->shortValue;
}
unsigned int
ASF::Attribute::toUInt() const
unsigned int ASF::Attribute::toUInt() const
{
return d->intValue;
}
unsigned long long
ASF::Attribute::toULongLong() const
unsigned long long ASF::Attribute::toULongLong() const
{
return d->longLongValue;
}
ASF::Picture
ASF::Attribute::toPicture() const
ASF::Picture ASF::Attribute::toPicture() const
{
return d->pictureValue;
}
String
ASF::Attribute::parse(ASF::File &f, int kind)
String ASF::Attribute::parse(ASF::File &f, int kind)
{
uint size, nameLength;
String name;
@ -261,8 +251,7 @@ ASF::Attribute::parse(ASF::File &f, int kind)
return name;
}
int
ASF::Attribute::dataSize() const
int ASF::Attribute::dataSize() const
{
switch (d->type) {
case WordType:
@ -284,8 +273,7 @@ ASF::Attribute::dataSize() const
return 0;
}
ByteVector
ASF::Attribute::render(const String &name, int kind) const
ByteVector ASF::Attribute::render(const String &name, int kind) const
{
ByteVector data;
@ -345,26 +333,22 @@ ASF::Attribute::render(const String &name, int kind) const
return data;
}
int
ASF::Attribute::language() const
int ASF::Attribute::language() const
{
return d->language;
}
void
ASF::Attribute::setLanguage(int value)
void ASF::Attribute::setLanguage(int value)
{
d->language = value;
}
int
ASF::Attribute::stream() const
int ASF::Attribute::stream() const
{
return d->stream;
}
void
ASF::Attribute::setStream(int value)
void ASF::Attribute::setStream(int value)
{
d->stream = value;
}

View File

@ -146,14 +146,12 @@ public:
ByteVector render(ASF::File *file);
};
void
ASF::File::BaseObject::parse(ASF::File *file, unsigned int size)
void ASF::File::BaseObject::parse(ASF::File *file, unsigned int size)
{
data = file->readBlock(size - 24);
}
ByteVector
ASF::File::BaseObject::render(ASF::File * /*file*/)
ByteVector ASF::File::BaseObject::render(ASF::File * /*file*/)
{
return guid() + ByteVector::fromLongLong(data.size() + 24, false) + data;
}
@ -162,33 +160,28 @@ ASF::File::UnknownObject::UnknownObject(const ByteVector &guid) : myGuid(guid)
{
}
ByteVector
ASF::File::UnknownObject::guid()
ByteVector ASF::File::UnknownObject::guid()
{
return myGuid;
}
ByteVector
ASF::File::FilePropertiesObject::guid()
ByteVector ASF::File::FilePropertiesObject::guid()
{
return filePropertiesGuid;
}
void
ASF::File::FilePropertiesObject::parse(ASF::File *file, uint size)
void ASF::File::FilePropertiesObject::parse(ASF::File *file, uint size)
{
BaseObject::parse(file, size);
file->d->properties->setLength((int)(data.mid(40, 8).toLongLong(false) / 10000000L - data.mid(56, 8).toLongLong(false) / 1000L));
}
ByteVector
ASF::File::StreamPropertiesObject::guid()
ByteVector ASF::File::StreamPropertiesObject::guid()
{
return streamPropertiesGuid;
}
void
ASF::File::StreamPropertiesObject::parse(ASF::File *file, uint size)
void ASF::File::StreamPropertiesObject::parse(ASF::File *file, uint size)
{
BaseObject::parse(file, size);
file->d->properties->setChannels(data.mid(56, 2).toShort(false));
@ -196,14 +189,12 @@ ASF::File::StreamPropertiesObject::parse(ASF::File *file, uint size)
file->d->properties->setBitrate(data.mid(62, 4).toUInt(false) * 8 / 1000);
}
ByteVector
ASF::File::ContentDescriptionObject::guid()
ByteVector ASF::File::ContentDescriptionObject::guid()
{
return contentDescriptionGuid;
}
void
ASF::File::ContentDescriptionObject::parse(ASF::File *file, uint /*size*/)
void ASF::File::ContentDescriptionObject::parse(ASF::File *file, uint /*size*/)
{
file->d->contentDescriptionObject = this;
int titleLength = file->readWORD();
@ -218,8 +209,7 @@ ASF::File::ContentDescriptionObject::parse(ASF::File *file, uint /*size*/)
file->d->tag->setRating(file->readString(ratingLength));
}
ByteVector
ASF::File::ContentDescriptionObject::render(ASF::File *file)
ByteVector ASF::File::ContentDescriptionObject::render(ASF::File *file)
{
ByteVector v1 = file->renderString(file->d->tag->title());
ByteVector v2 = file->renderString(file->d->tag->artist());
@ -240,14 +230,12 @@ ASF::File::ContentDescriptionObject::render(ASF::File *file)
return BaseObject::render(file);
}
ByteVector
ASF::File::ExtendedContentDescriptionObject::guid()
ByteVector ASF::File::ExtendedContentDescriptionObject::guid()
{
return extendedContentDescriptionGuid;
}
void
ASF::File::ExtendedContentDescriptionObject::parse(ASF::File *file, uint /*size*/)
void ASF::File::ExtendedContentDescriptionObject::parse(ASF::File *file, uint /*size*/)
{
file->d->extendedContentDescriptionObject = this;
int count = file->readWORD();
@ -258,8 +246,7 @@ ASF::File::ExtendedContentDescriptionObject::parse(ASF::File *file, uint /*size*
}
}
ByteVector
ASF::File::ExtendedContentDescriptionObject::render(ASF::File *file)
ByteVector ASF::File::ExtendedContentDescriptionObject::render(ASF::File *file)
{
data.clear();
data.append(ByteVector::fromShort(attributeData.size(), false));
@ -267,14 +254,12 @@ ASF::File::ExtendedContentDescriptionObject::render(ASF::File *file)
return BaseObject::render(file);
}
ByteVector
ASF::File::MetadataObject::guid()
ByteVector ASF::File::MetadataObject::guid()
{
return metadataGuid;
}
void
ASF::File::MetadataObject::parse(ASF::File *file, uint /*size*/)
void ASF::File::MetadataObject::parse(ASF::File *file, uint /*size*/)
{
file->d->metadataObject = this;
int count = file->readWORD();
@ -285,8 +270,7 @@ ASF::File::MetadataObject::parse(ASF::File *file, uint /*size*/)
}
}
ByteVector
ASF::File::MetadataObject::render(ASF::File *file)
ByteVector ASF::File::MetadataObject::render(ASF::File *file)
{
data.clear();
data.append(ByteVector::fromShort(attributeData.size(), false));
@ -294,14 +278,12 @@ ASF::File::MetadataObject::render(ASF::File *file)
return BaseObject::render(file);
}
ByteVector
ASF::File::MetadataLibraryObject::guid()
ByteVector ASF::File::MetadataLibraryObject::guid()
{
return metadataLibraryGuid;
}
void
ASF::File::MetadataLibraryObject::parse(ASF::File *file, uint /*size*/)
void ASF::File::MetadataLibraryObject::parse(ASF::File *file, uint /*size*/)
{
file->d->metadataLibraryObject = this;
int count = file->readWORD();
@ -312,8 +294,7 @@ ASF::File::MetadataLibraryObject::parse(ASF::File *file, uint /*size*/)
}
}
ByteVector
ASF::File::MetadataLibraryObject::render(ASF::File *file)
ByteVector ASF::File::MetadataLibraryObject::render(ASF::File *file)
{
data.clear();
data.append(ByteVector::fromShort(attributeData.size(), false));
@ -321,14 +302,12 @@ ASF::File::MetadataLibraryObject::render(ASF::File *file)
return BaseObject::render(file);
}
ByteVector
ASF::File::HeaderExtensionObject::guid()
ByteVector ASF::File::HeaderExtensionObject::guid()
{
return headerExtensionGuid;
}
void
ASF::File::HeaderExtensionObject::parse(ASF::File *file, uint /*size*/)
void ASF::File::HeaderExtensionObject::parse(ASF::File *file, uint /*size*/)
{
file->d->headerExtensionObject = this;
file->seek(18, File::Current);
@ -353,8 +332,7 @@ ASF::File::HeaderExtensionObject::parse(ASF::File *file, uint /*size*/)
}
}
ByteVector
ASF::File::HeaderExtensionObject::render(ASF::File *file)
ByteVector ASF::File::HeaderExtensionObject::render(ASF::File *file)
{
data.clear();
for(unsigned int i = 0; i < objects.size(); i++) {
@ -533,8 +511,7 @@ long long ASF::File::readQWORD()
return v.toLongLong(false);
}
String
ASF::File::readString(int length)
String ASF::File::readString(int length)
{
ByteVector data = readBlock(length);
unsigned int size = data.size();
@ -550,8 +527,7 @@ ASF::File::readString(int length)
return String(data, String::UTF16LE);
}
ByteVector
ASF::File::renderString(const String &str, bool includeLength)
ByteVector ASF::File::renderString(const String &str, bool includeLength)
{
ByteVector data = str.data(String::UTF16LE) + ByteVector::fromShort(0, false);
if(includeLength) {

View File

@ -56,54 +56,46 @@ ASF::Tag::~Tag()
delete d;
}
String
ASF::Tag::title() const
String ASF::Tag::title() const
{
return d->title;
}
String
ASF::Tag::artist() const
String ASF::Tag::artist() const
{
return d->artist;
}
String
ASF::Tag::album() const
String ASF::Tag::album() const
{
if(d->attributeListMap.contains("WM/AlbumTitle"))
return d->attributeListMap["WM/AlbumTitle"][0].toString();
return String::null;
}
String
ASF::Tag::copyright() const
String ASF::Tag::copyright() const
{
return d->copyright;
}
String
ASF::Tag::comment() const
String ASF::Tag::comment() const
{
return d->comment;
}
String
ASF::Tag::rating() const
String ASF::Tag::rating() const
{
return d->rating;
}
unsigned int
ASF::Tag::year() const
unsigned int ASF::Tag::year() const
{
if(d->attributeListMap.contains("WM/Year"))
return d->attributeListMap["WM/Year"][0].toString().toInt();
return 0;
}
unsigned int
ASF::Tag::track() const
unsigned int ASF::Tag::track() const
{
if(d->attributeListMap.contains("WM/TrackNumber")) {
const ASF::Attribute attr = d->attributeListMap["WM/TrackNumber"][0];
@ -117,70 +109,59 @@ ASF::Tag::track() const
return 0;
}
String
ASF::Tag::genre() const
String ASF::Tag::genre() const
{
if(d->attributeListMap.contains("WM/Genre"))
return d->attributeListMap["WM/Genre"][0].toString();
return String::null;
}
void
ASF::Tag::setTitle(const String &value)
void ASF::Tag::setTitle(const String &value)
{
d->title = value;
}
void
ASF::Tag::setArtist(const String &value)
void ASF::Tag::setArtist(const String &value)
{
d->artist = value;
}
void
ASF::Tag::setCopyright(const String &value)
void ASF::Tag::setCopyright(const String &value)
{
d->copyright = value;
}
void
ASF::Tag::setComment(const String &value)
void ASF::Tag::setComment(const String &value)
{
d->comment = value;
}
void
ASF::Tag::setRating(const String &value)
void ASF::Tag::setRating(const String &value)
{
d->rating = value;
}
void
ASF::Tag::setAlbum(const String &value)
void ASF::Tag::setAlbum(const String &value)
{
setAttribute("WM/AlbumTitle", value);
}
void
ASF::Tag::setGenre(const String &value)
void ASF::Tag::setGenre(const String &value)
{
setAttribute("WM/Genre", value);
}
void
ASF::Tag::setYear(uint value)
void ASF::Tag::setYear(uint value)
{
setAttribute("WM/Year", String::number(value));
}
void
ASF::Tag::setTrack(uint value)
void ASF::Tag::setTrack(uint value)
{
setAttribute("WM/TrackNumber", String::number(value));
}
ASF::AttributeListMap&
ASF::Tag::attributeListMap()
ASF::AttributeListMap& ASF::Tag::attributeListMap()
{
return d->attributeListMap;
}
@ -209,7 +190,8 @@ void ASF::Tag::addAttribute(const String &name, const Attribute &attribute)
}
}
bool ASF::Tag::isEmpty() const {
bool ASF::Tag::isEmpty() const
{
return TagLib::Tag::isEmpty() &&
copyright().isEmpty() &&
rating().isEmpty() &&