Additional manual formatting to taglib sources

This commit is contained in:
Jonas Kvinge
2020-06-14 17:01:05 +02:00
parent 577b7d8ec8
commit ef34dce4dc
217 changed files with 7367 additions and 8204 deletions

View File

@@ -35,26 +35,24 @@ using namespace Mod;
class Mod::File::FilePrivate {
public:
explicit FilePrivate(AudioProperties::ReadStyle propertiesStyle)
: properties(propertiesStyle) {
}
explicit FilePrivate(AudioProperties::ReadStyle propertiesStyle) : properties(propertiesStyle) {}
Mod::Tag tag;
Mod::Properties properties;
};
Mod::File::File(FileName file, bool readProperties,
AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(file),
d(new FilePrivate(propertiesStyle)) {
Mod::File::File(FileName file, bool readProperties, AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(file), d(new FilePrivate(propertiesStyle)) {
if (isOpen())
read(readProperties);
}
Mod::File::File(IOStream *stream, bool readProperties,
AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(stream),
d(new FilePrivate(propertiesStyle)) {
Mod::File::File(IOStream *stream, bool readProperties, AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(stream), d(new FilePrivate(propertiesStyle)) {
if (isOpen())
read(readProperties);
}
Mod::File::~File() {
@@ -78,6 +76,7 @@ PropertyMap Mod::File::setProperties(const PropertyMap &properties) {
}
bool Mod::File::save() {
if (readOnly()) {
debug("Mod::File::save() - Cannot save to a read only file.");
return false;
@@ -96,9 +95,11 @@ bool Mod::File::save() {
seek(8, Current);
}
return true;
}
void Mod::File::read(bool) {
if (!isOpen())
return;
@@ -176,4 +177,5 @@ void Mod::File::read(bool) {
READ_BYTE(d->properties.setLengthInPatterns);
d->tag.setComment(comment.toString("\n"));
}

View File

@@ -35,66 +35,58 @@
namespace Strawberry_TagLib {
namespace TagLib {
namespace Mod {
class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::Mod::FileBase {
public:
/*!
* Constructs a Protracker file from \a file.
*
* \note In the current implementation, both \a readProperties and
* \a propertiesStyle are ignored. The audio properties are always
* read.
*/
File(FileName file, bool readProperties = true,
AudioProperties::ReadStyle propertiesStyle =
AudioProperties::Average);
* Constructs a Protracker file from \a file.
*
* \note In the current implementation, both \a readProperties and \a propertiesStyle are ignored.
* The audio properties are always read.
*/
File(FileName file, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average);
/*!
* Constructs a Protracker file from \a stream.
*
* \note In the current implementation, both \a readProperties and
* \a propertiesStyle are ignored. The audio properties are always
* read.
*
* \note TagLib will *not* take ownership of the stream, the caller is
* responsible for deleting it after the File object.
*/
File(IOStream *stream, bool readProperties = true,
AudioProperties::ReadStyle propertiesStyle =
AudioProperties::Average);
* Constructs a Protracker file from \a stream.
*
* \note In the current implementation, both \a readProperties and \a propertiesStyle are ignored.
* The audio properties are always read.
*
* \note TagLib will *not* take ownership of the stream, the caller is
* responsible for deleting it after the File object.
*/
File(IOStream *stream, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average);
/*!
* Destroys this instance of the File.
*/
* Destroys this instance of the File.
*/
virtual ~File();
Mod::Tag *tag() const;
/*!
* Implements the unified property interface -- export function.
* Forwards to Mod::Tag::properties().
*/
* Implements the unified property interface -- export function.
* Forwards to Mod::Tag::properties().
*/
PropertyMap properties() const;
/*!
* Implements the unified property interface -- import function.
* Forwards to Mod::Tag::setProperties().
*/
* Implements the unified property interface -- import function.
* Forwards to Mod::Tag::setProperties().
*/
PropertyMap setProperties(const PropertyMap &);
/*!
* Returns the Mod::Properties for this file. If no audio properties
* were read then this will return a null pointer.
*/
* Returns the Mod::Properties for this file. If no audio properties were read then this will return a null pointer.
*/
Mod::Properties *audioProperties() const;
/*!
* Save the file.
* This is the same as calling save(AllTags);
*
* \note Saving Protracker tags is not supported.
*/
* Save the file.
* This is the same as calling save(AllTags);
*
* \note Saving Protracker tags is not supported.
*/
bool save();
private:
@@ -108,7 +100,6 @@ class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::Mod::FileBase {
};
} // namespace Mod
} // namespace TagLib
} // namespace Strawberry_TagLib

View File

@@ -30,11 +30,9 @@
using namespace Strawberry_TagLib::TagLib;
using namespace Mod;
Mod::FileBase::FileBase(FileName file) : Strawberry_TagLib::TagLib::File(file) {
}
Mod::FileBase::FileBase(FileName file) : Strawberry_TagLib::TagLib::File(file) {}
Mod::FileBase::FileBase(IOStream *stream) : Strawberry_TagLib::TagLib::File(stream) {
}
Mod::FileBase::FileBase(IOStream *stream) : Strawberry_TagLib::TagLib::File(stream) {}
void Mod::FileBase::writeString(const String &s, unsigned long size, char padding) {
ByteVector data(s.data(String::Latin1));
@@ -43,6 +41,7 @@ void Mod::FileBase::writeString(const String &s, unsigned long size, char paddin
}
bool Mod::FileBase::readString(String &s, unsigned long size) {
ByteVector data(readBlock(size));
if (data.size() < size) return false;
int index = data.find((char)0);
@@ -53,6 +52,7 @@ bool Mod::FileBase::readString(String &s, unsigned long size) {
s = data;
return true;
}
void Mod::FileBase::writeByte(unsigned char _byte) {
@@ -77,36 +77,46 @@ void Mod::FileBase::writeU32B(unsigned long number) {
}
bool Mod::FileBase::readByte(unsigned char &_byte) {
ByteVector data(readBlock(1));
if (data.size() < 1) return false;
_byte = data[0];
return true;
}
bool Mod::FileBase::readU16L(unsigned short &number) {
ByteVector data(readBlock(2));
if (data.size() < 2) return false;
number = data.toUShort(false);
return true;
}
bool Mod::FileBase::readU32L(unsigned long &number) {
ByteVector data(readBlock(4));
if (data.size() < 4) return false;
number = data.toUInt(false);
return true;
}
bool Mod::FileBase::readU16B(unsigned short &number) {
ByteVector data(readBlock(2));
if (data.size() < 2) return false;
number = data.toUShort(true);
return true;
}
bool Mod::FileBase::readU32B(unsigned long &number) {
ByteVector data(readBlock(4));
if (data.size() < 4) return false;
number = data.toUInt(true);
return true;
}

View File

@@ -36,7 +36,6 @@
namespace Strawberry_TagLib {
namespace TagLib {
namespace Mod {
class TAGLIB_EXPORT FileBase : public Strawberry_TagLib::TagLib::File {
@@ -60,7 +59,6 @@ class TAGLIB_EXPORT FileBase : public Strawberry_TagLib::TagLib::File {
};
} // namespace Mod
} // namespace TagLib
} // namespace Strawberry_TagLib

View File

@@ -31,18 +31,14 @@ using namespace Mod;
class Mod::Properties::PropertiesPrivate {
public:
PropertiesPrivate() : channels(0),
instrumentCount(0),
lengthInPatterns(0) {
}
PropertiesPrivate() : channels(0), instrumentCount(0), lengthInPatterns(0) {}
int channels;
unsigned int instrumentCount;
unsigned char lengthInPatterns;
};
Mod::Properties::Properties(AudioProperties::ReadStyle propertiesStyle) : AudioProperties(propertiesStyle),
d(new PropertiesPrivate()) {
Mod::Properties::Properties(AudioProperties::ReadStyle propertiesStyle) : AudioProperties(propertiesStyle), d(new PropertiesPrivate()) {
}
Mod::Properties::~Properties() {

View File

@@ -31,7 +31,6 @@
namespace Strawberry_TagLib {
namespace TagLib {
namespace Mod {
class TAGLIB_EXPORT Properties : public AudioProperties {
@@ -65,7 +64,6 @@ class TAGLIB_EXPORT Properties : public AudioProperties {
};
} // namespace Mod
} // namespace TagLib
} // namespace Strawberry_TagLib

View File

@@ -33,17 +33,14 @@ using namespace Mod;
class Mod::Tag::TagPrivate {
public:
TagPrivate() {
}
TagPrivate() {}
String title;
String comment;
String trackerName;
};
Mod::Tag::Tag() : Strawberry_TagLib::TagLib::Tag(),
d(new TagPrivate()) {
}
Mod::Tag::Tag() : Strawberry_TagLib::TagLib::Tag(), d(new TagPrivate()) {}
Mod::Tag::~Tag() {
delete d;
@@ -109,15 +106,18 @@ void Mod::Tag::setTrackerName(const String &trackerName) {
}
PropertyMap Mod::Tag::properties() const {
PropertyMap properties;
properties["TITLE"] = d->title;
properties["COMMENT"] = d->comment;
if (!(d->trackerName.isEmpty()))
properties["TRACKERNAME"] = d->trackerName;
return properties;
}
PropertyMap Mod::Tag::setProperties(const PropertyMap &origProps) {
PropertyMap properties(origProps);
properties.removeEmpty();
StringList oneValueSet;
@@ -151,4 +151,5 @@ PropertyMap Mod::Tag::setProperties(const PropertyMap &origProps) {
properties[*it].erase(properties[*it].begin());
}
return properties;
}

View File

@@ -30,153 +30,141 @@
namespace Strawberry_TagLib {
namespace TagLib {
namespace Mod {
/*!
* Tags for module files (Mod, S3M, IT, XM).
*
* Note that only the \a title is supported as such by most
* module file formats. Except for XM files the \a trackerName
* is derived from the file format or the flavour of the file
* format. For XM files it is stored in the file.
*
* The \a comment tag is not strictly supported by module files,
* but it is common practice to abuse instrument/sample/pattern
* names as multiline comments. TagLib does so as well.
*/
* Tags for module files (Mod, S3M, IT, XM).
*
* Note that only the \a title is supported as such by most module file formats.
* Except for XM files the \a trackerName is derived from the file format or the flavour of the file format.
* For XM files it is stored in the file.
*
* The \a comment tag is not strictly supported by module files,
* but it is common practice to abuse instrument/sample/pattern names as multiline comments.
* TagLib does so as well.
*
*/
class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
public:
Tag();
virtual ~Tag();
/*!
* Returns the track name; if no track name is present in the tag
* String::null will be returned.
*/
* Returns the track name; if no track name is present in the tag String::null will be returned.
*/
virtual String title() const;
/*!
* Not supported by module files. Therefore always returns String::null.
*/
* Not supported by module files. Therefore always returns String::null.
*/
virtual String artist() const;
/*!
* Not supported by module files. Therefore always returns String::null.
*/
* Not supported by module files. Therefore always returns String::null.
*/
virtual String album() const;
/*!
* Returns the track comment derived from the instrument/sample/pattern
* names; if no comment is present in the tag String::null will be
* returned.
*/
* Returns the track comment derived from the instrument/sample/pattern
* names; if no comment is present in the tag String::null will be returned.
*/
virtual String comment() const;
/*!
* Not supported by module files. Therefore always returns String::null.
*/
* Not supported by module files. Therefore always returns String::null.
*/
virtual String genre() const;
/*!
* Not supported by module files. Therefore always returns 0.
*/
* Not supported by module files. Therefore always returns 0.
*/
virtual unsigned int year() const;
/*!
* Not supported by module files. Therefore always returns 0.
*/
* Not supported by module files. Therefore always returns 0.
*/
virtual unsigned int track() const;
/*!
* Returns the name of the tracker used to create/edit the module file.
* Only XM files store this tag to the file as such, for other formats
* (Mod, S3M, IT) this is derived from the file type or the flavour of
* the file type. Therefore only XM files might have an empty
* (String::null) tracker name.
*/
* Returns the name of the tracker used to create/edit the module file.
* Only XM files store this tag to the file as such, for other formats
* (Mod, S3M, IT) this is derived from the file type or the flavour of the file type.
* Therefore only XM files might have an empty (String::null) tracker name.
*/
String trackerName() const;
/*!
* Sets the title to \a title. If \a title is String::null then this
* value will be cleared.
*
* The length limits per file type are (1 character = 1 byte):
* Mod 20 characters, S3M 27 characters, IT 25 characters and XM 20
* characters.
*/
* Sets the title to \a title.
* If \a title is String::null then this value will be cleared.
*
* The length limits per file type are (1 character = 1 byte):
* Mod 20 characters, S3M 27 characters, IT 25 characters and XM 20 characters.
*/
virtual void setTitle(const String &title);
/*!
* Not supported by module files and therefore ignored.
*/
* Not supported by module files and therefore ignored.
*/
virtual void setArtist(const String &artist);
/*!
* Not supported by module files and therefore ignored.
*/
* Not supported by module files and therefore ignored.
*/
virtual void setAlbum(const String &album);
/*!
* Sets the comment to \a comment. If \a comment is String::null then
* this value will be cleared.
*
* Note that module file formats don't actually support a comment tag.
* Instead the names of instruments/patterns/samples are abused as
* a multiline comment. Because of this the number of lines in a
* module file is fixed to the number of instruments/patterns/samples.
*
* Also note that the instrument/pattern/sample name length is limited
* an thus the line length in comments are limited. Too big comments
* will be truncated.
*
* The line length limits per file type are (1 character = 1 byte):
* Mod 22 characters, S3M 27 characters, IT 25 characters and XM 22
* characters.
*/
* Sets the comment to \a comment.
* If \a comment is String::null then this value will be cleared.
*
* Note that module file formats don't actually support a comment tag.
* Instead the names of instruments/patterns/samples are abused as a multiline comment.
* Because of this the number of lines in a module file is fixed to the number of instruments/patterns/samples.
*
* Also note that the instrument/pattern/sample name length is limited an thus the line length in comments are limited.
* Too big comments will be truncated.
*
* The line length limits per file type are (1 character = 1 byte):
* Mod 22 characters, S3M 27 characters, IT 25 characters and XM 22 characters.
*/
virtual void setComment(const String &comment);
/*!
* Not supported by module files and therefore ignored.
*/
* Not supported by module files and therefore ignored.
*/
virtual void setGenre(const String &genre);
/*!
* Not supported by module files and therefore ignored.
*/
* Not supported by module files and therefore ignored.
*/
virtual void setYear(unsigned int year);
/*!
* Not supported by module files and therefore ignored.
*/
* Not supported by module files and therefore ignored.
*/
virtual void setTrack(unsigned int track);
/*!
* Sets the tracker name to \a trackerName. If \a trackerName is
* String::null then this value will be cleared.
*
* Note that only XM files support this tag. Setting the
* tracker name for other module file formats will be ignored.
*
* The length of this tag is limited to 20 characters (1 character
* = 1 byte).
*/
* Sets the tracker name to \a trackerName.
* If \a trackerName is String::null then this value will be cleared.
*
* Note that only XM files support this tag.
* Setting the tracker name for other module file formats will be ignored.
*
* The length of this tag is limited to 20 characters (1 character = 1 byte).
*/
void setTrackerName(const String &trackerName);
/*!
* Implements the unified property interface -- export function.
* Since the module tag is very limited, the exported map is as well.
*/
* Implements the unified property interface -- export function.
* Since the module tag is very limited, the exported map is as well.
*/
PropertyMap properties() const;
/*!
* Implements the unified property interface -- import function.
* Because of the limitations of the module file tag, any tags besides
* COMMENT, TITLE and, if it is an XM file, TRACKERNAME, will be
* returned. Additionally, if the map contains tags with multiple values,
* all but the first will be contained in the returned map of unsupported
* properties.
*/
* Implements the unified property interface -- import function.
* Because of the limitations of the module file tag, any tags besides COMMENT, TITLE and, if it is an XM file, TRACKERNAME, will be returned.
* Additionally, if the map contains tags with multiple values, all but the first will be contained in the returned map of unsupported properties.
*/
PropertyMap setProperties(const PropertyMap &);
private:
@@ -188,7 +176,6 @@ class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
};
} // namespace Mod
} // namespace TagLib
} // namespace Strawberry_TagLib