From c2c9e8989c15b1d91e3bd6b6b3fb561afdaa047a Mon Sep 17 00:00:00 2001 From: Urs Fleisch Date: Sun, 16 Jul 2023 06:13:34 +0200 Subject: [PATCH] clang-tidy: Use auto where it improves the readability run-clang-tidy -header-filter='.*' -checks='-*,modernize-use-auto' \ -config="{CheckOptions: [{key: modernize-use-auto.RemoveStars, value: '1'}]}" \ -fix Manually fixed some wrong `const auto` replacements and verified that all types are deduced correctly. --- bindings/c/tag_c.cpp | 24 +++--- examples/framelist.cpp | 6 +- examples/tagreader.cpp | 6 +- examples/tagwriter.cpp | 6 +- taglib/ape/apeitem.cpp | 4 +- taglib/ape/apetag.cpp | 18 ++--- taglib/asf/asffile.cpp | 10 +-- taglib/asf/asftag.cpp | 10 +-- taglib/fileref.cpp | 6 +- taglib/flac/flacfile.cpp | 14 ++-- taglib/it/itfile.cpp | 2 +- taglib/mod/modtag.cpp | 2 +- taglib/mp4/mp4atom.cpp | 14 ++-- taglib/mp4/mp4file.cpp | 2 +- taglib/mp4/mp4properties.cpp | 4 +- taglib/mp4/mp4tag.cpp | 56 +++++++------- .../id3v2/frames/attachedpictureframe.cpp | 2 +- taglib/mpeg/id3v2/frames/chapterframe.cpp | 14 ++-- taglib/mpeg/id3v2/frames/commentsframe.cpp | 4 +- .../id3v2/frames/eventtimingcodesframe.cpp | 4 +- .../mpeg/id3v2/frames/relativevolumeframe.cpp | 6 +- .../id3v2/frames/synchronizedlyricsframe.cpp | 4 +- .../id3v2/frames/tableofcontentsframe.cpp | 24 +++--- .../id3v2/frames/textidentificationframe.cpp | 28 +++---- .../frames/uniquefileidentifierframe.cpp | 4 +- .../frames/unsynchronizedlyricsframe.cpp | 4 +- taglib/mpeg/id3v2/frames/urllinkframe.cpp | 4 +- taglib/mpeg/id3v2/id3v2frame.cpp | 18 ++--- taglib/mpeg/id3v2/id3v2framefactory.cpp | 20 ++--- taglib/mpeg/id3v2/id3v2header.cpp | 2 +- taglib/mpeg/id3v2/id3v2synchdata.cpp | 4 +- taglib/mpeg/id3v2/id3v2tag.cpp | 50 ++++++------- taglib/ogg/oggfile.cpp | 6 +- taglib/ogg/oggpage.cpp | 12 +-- taglib/ogg/oggpageheader.cpp | 2 +- taglib/ogg/xiphcomment.cpp | 26 +++---- taglib/riff/rifffile.cpp | 4 +- taglib/riff/riffutils.h | 2 +- taglib/riff/wav/infotag.cpp | 2 +- taglib/tag.cpp | 2 +- taglib/toolkit/tbytevector.cpp | 6 +- taglib/toolkit/tbytevectorlist.cpp | 2 +- taglib/toolkit/tfilestream.cpp | 4 +- taglib/toolkit/tlist.tcc | 6 +- taglib/toolkit/tmap.tcc | 2 +- taglib/toolkit/tpropertymap.cpp | 22 +++--- taglib/toolkit/tstring.cpp | 2 +- taglib/toolkit/tstringlist.cpp | 6 +- taglib/wavpack/wavpackproperties.cpp | 4 +- taglib/xm/xmfile.cpp | 4 +- tests/test_bytevector.cpp | 8 +- tests/test_flac.cpp | 6 +- tests/test_flacpicture.cpp | 5 +- tests/test_id3v2.cpp | 73 ++++++++----------- tests/test_list.cpp | 2 +- tests/test_map.cpp | 2 +- tests/test_xiphcomment.cpp | 2 +- 57 files changed, 289 insertions(+), 299 deletions(-) diff --git a/bindings/c/tag_c.cpp b/bindings/c/tag_c.cpp index 7ffb378f..b779bb81 100644 --- a/bindings/c/tag_c.cpp +++ b/bindings/c/tag_c.cpp @@ -136,13 +136,13 @@ BOOL taglib_file_is_valid(const TagLib_File *file) TagLib_Tag *taglib_file_tag(const TagLib_File *file) { - const File *f = reinterpret_cast(file); + auto f = reinterpret_cast(file); return reinterpret_cast(f->tag()); } const TagLib_AudioProperties *taglib_file_audioproperties(const TagLib_File *file) { - const File *f = reinterpret_cast(file); + auto f = reinterpret_cast(file); return reinterpret_cast(f->audioProperties()); } @@ -259,7 +259,7 @@ void taglib_tag_free_strings() if(!stringManagementEnabled) return; - for(List::ConstIterator it = strings.cbegin(); it != strings.cend(); ++it) + for(auto it = strings.cbegin(); it != strings.cend(); ++it) free(*it); strings.clear(); } @@ -270,25 +270,25 @@ void taglib_tag_free_strings() int taglib_audioproperties_length(const TagLib_AudioProperties *audioProperties) { - const AudioProperties *p = reinterpret_cast(audioProperties); + auto p = reinterpret_cast(audioProperties); return p->lengthInSeconds(); } int taglib_audioproperties_bitrate(const TagLib_AudioProperties *audioProperties) { - const AudioProperties *p = reinterpret_cast(audioProperties); + auto p = reinterpret_cast(audioProperties); return p->bitrate(); } int taglib_audioproperties_samplerate(const TagLib_AudioProperties *audioProperties) { - const AudioProperties *p = reinterpret_cast(audioProperties); + auto p = reinterpret_cast(audioProperties); return p->sampleRate(); } int taglib_audioproperties_channels(const TagLib_AudioProperties *audioProperties) { - const AudioProperties *p = reinterpret_cast(audioProperties); + auto p = reinterpret_cast(audioProperties); return p->channels(); } @@ -326,11 +326,11 @@ void _taglib_property_set(TagLib_File *file, const char* prop, const char* value if(file == NULL || prop == NULL) return; - File *tfile = reinterpret_cast(file); + auto tfile = reinterpret_cast(file); PropertyMap map = tfile->tag()->properties(); if(value) { - TagLib::PropertyMap::Iterator property = map.find(prop); + auto property = map.find(prop); if(property == map.end()) { map.insert(prop, StringList(value)); } @@ -371,7 +371,7 @@ char** taglib_property_keys(TagLib_File *file) if(map.isEmpty()) return NULL; - char **props = static_cast(malloc(sizeof(char *) * (map.size() + 1))); + auto props = static_cast(malloc(sizeof(char *) * (map.size() + 1))); char **pp = props; for(const auto &i : map) { @@ -389,11 +389,11 @@ char **taglib_property_get(TagLib_File *file, const char *prop) const PropertyMap map = reinterpret_cast(file)->properties(); - TagLib::PropertyMap::ConstIterator property = map.find(prop); + auto property = map.find(prop); if(property == map.end()) return NULL; - char **props = static_cast(malloc(sizeof(char *) * (property->second.size() + 1))); + auto props = static_cast(malloc(sizeof(char *) * (property->second.size() + 1))); char **pp = props; for(const auto &i : property->second) { diff --git a/examples/framelist.cpp b/examples/framelist.cpp index 44914cc9..37b692c2 100644 --- a/examples/framelist.cpp +++ b/examples/framelist.cpp @@ -65,11 +65,11 @@ int main(int argc, char *argv[]) << " bytes in tag" << endl; - ID3v2::FrameList::ConstIterator it = id3v2tag->frameList().begin(); + auto it = id3v2tag->frameList().begin(); for(; it != id3v2tag->frameList().end(); it++) { cout << (*it)->frameID(); - if(ID3v2::CommentsFrame *comment = dynamic_cast(*it)) + if(auto comment = dynamic_cast(*it)) if(!comment->description().isEmpty()) cout << " [" << comment->description() << "]"; @@ -100,7 +100,7 @@ int main(int argc, char *argv[]) cout << endl << "APE" << endl; if(ape) { - for(APE::ItemListMap::ConstIterator it = ape->itemListMap().begin(); + for(auto it = ape->itemListMap().begin(); it != ape->itemListMap().end(); ++it) { if((*it).second.type() != APE::Item::Binary) diff --git a/examples/tagreader.cpp b/examples/tagreader.cpp index 1c67f097..0d6b5191 100644 --- a/examples/tagreader.cpp +++ b/examples/tagreader.cpp @@ -56,15 +56,15 @@ int main(int argc, char *argv[]) TagLib::PropertyMap tags = f.file()->properties(); unsigned int longest = 0; - for(TagLib::PropertyMap::ConstIterator i = tags.cbegin(); i != tags.cend(); ++i) { + for(auto i = tags.cbegin(); i != tags.cend(); ++i) { if (i->first.size() > longest) { longest = i->first.size(); } } cout << "-- TAG (properties) --" << endl; - for(TagLib::PropertyMap::ConstIterator i = tags.cbegin(); i != tags.cend(); ++i) { - for(TagLib::StringList::ConstIterator j = i->second.begin(); j != i->second.end(); ++j) { + for(auto i = tags.cbegin(); i != tags.cend(); ++i) { + for(auto j = i->second.begin(); j != i->second.end(); ++j) { cout << left << std::setw(longest) << i->first << " - " << '"' << *j << '"' << endl; } } diff --git a/examples/tagwriter.cpp b/examples/tagwriter.cpp index d935f36b..0f094cd0 100644 --- a/examples/tagwriter.cpp +++ b/examples/tagwriter.cpp @@ -79,14 +79,14 @@ void checkForRejectedProperties(const TagLib::PropertyMap &tags) { // stolen from tagreader.cpp if(tags.size() > 0) { unsigned int longest = 0; - for(TagLib::PropertyMap::ConstIterator i = tags.begin(); i != tags.end(); ++i) { + for(auto i = tags.begin(); i != tags.end(); ++i) { if(i->first.size() > longest) { longest = i->first.size(); } } cout << "-- rejected TAGs (properties) --" << endl; - for(TagLib::PropertyMap::ConstIterator i = tags.begin(); i != tags.end(); ++i) { - for(TagLib::StringList::ConstIterator j = i->second.begin(); j != i->second.end(); ++j) { + for(auto i = tags.begin(); i != tags.end(); ++i) { + for(auto j = i->second.begin(); j != i->second.end(); ++j) { cout << left << std::setw(longest) << i->first << " - " << '"' << *j << '"' << endl; } } diff --git a/taglib/ape/apeitem.cpp b/taglib/ape/apeitem.cpp index 7e4a91e3..e1422996 100644 --- a/taglib/ape/apeitem.cpp +++ b/taglib/ape/apeitem.cpp @@ -181,7 +181,7 @@ int APE::Item::size() const switch(d->type) { case Text: if(!d->text.isEmpty()) { - StringList::ConstIterator it = d->text.cbegin(); + auto it = d->text.cbegin(); result += it->data(String::UTF8).size(); it++; @@ -268,7 +268,7 @@ ByteVector APE::Item::render() const return data; if(d->type == Text) { - StringList::ConstIterator it = d->text.cbegin(); + auto it = d->text.cbegin(); value.append(it->data(String::UTF8)); it++; diff --git a/taglib/ape/apetag.cpp b/taglib/ape/apetag.cpp index ae74e021..879c524a 100644 --- a/taglib/ape/apetag.cpp +++ b/taglib/ape/apetag.cpp @@ -56,7 +56,7 @@ namespace // only allow printable ASCII including space (32..126) - for(ByteVector::ConstIterator it = key.begin(); it != key.end(); ++it) { + for(auto it = key.begin(); it != key.end(); ++it) { const int c = static_cast(*it); if(c < 32 || c > 126) return false; @@ -217,7 +217,7 @@ namespace PropertyMap APE::Tag::properties() const { PropertyMap properties; - ItemListMap::ConstIterator it = itemListMap().begin(); + auto it = itemListMap().begin(); for(; it != itemListMap().end(); ++it) { String tagName = it->first.upper(); // if the item is Binary or Locator, or if the key is an invalid string, @@ -239,7 +239,7 @@ PropertyMap APE::Tag::properties() const void APE::Tag::removeUnsupportedProperties(const StringList &properties) { - StringList::ConstIterator it = properties.begin(); + auto it = properties.begin(); for(; it != properties.end(); ++it) removeItem(*it); } @@ -257,7 +257,7 @@ PropertyMap APE::Tag::setProperties(const PropertyMap &origProps) // first check if tags need to be removed completely StringList toRemove; - ItemListMap::ConstIterator remIt = itemListMap().begin(); + auto remIt = itemListMap().begin(); for(; remIt != itemListMap().end(); ++remIt) { String key = remIt->first.upper(); // only remove if a) key is valid, b) type is text, c) key not contained in new properties @@ -265,11 +265,11 @@ PropertyMap APE::Tag::setProperties(const PropertyMap &origProps) toRemove.append(remIt->first); } - for(StringList::ConstIterator removeIt = toRemove.cbegin(); removeIt != toRemove.cend(); removeIt++) + for(auto removeIt = toRemove.cbegin(); removeIt != toRemove.cend(); removeIt++) removeItem(*removeIt); // now sync in the "forward direction" - PropertyMap::ConstIterator it = properties.cbegin(); + auto it = properties.cbegin(); PropertyMap invalid; for(; it != properties.cend(); ++it) { const String &tagName = it->first; @@ -279,7 +279,7 @@ PropertyMap APE::Tag::setProperties(const PropertyMap &origProps) if(it->second.isEmpty()) removeItem(tagName); else { - StringList::ConstIterator valueIt = it->second.begin(); + auto valueIt = it->second.begin(); addValue(tagName, *valueIt, true); ++valueIt; for(; valueIt != it->second.end(); ++valueIt) @@ -324,7 +324,7 @@ void APE::Tag::addValue(const String &key, const String &value, bool replace) // Text items may contain more than one value. // Binary or locator items may have only one value, hence always replaced. - ItemListMap::Iterator it = d->itemListMap.find(key.upper()); + auto it = d->itemListMap.find(key.upper()); if(it != d->itemListMap.end() && it->second.type() == Item::Text) it->second.appendValue(value); @@ -382,7 +382,7 @@ ByteVector APE::Tag::render() const ByteVector data; unsigned int itemCount = 0; - for(ItemListMap::ConstIterator it = d->itemListMap.cbegin(); it != d->itemListMap.cend(); ++it) { + for(auto it = d->itemListMap.cbegin(); it != d->itemListMap.cend(); ++it) { data.append(it->second.render()); itemCount++; } diff --git a/taglib/asf/asffile.cpp b/taglib/asf/asffile.cpp index 967faae2..00d463c0 100644 --- a/taglib/asf/asffile.cpp +++ b/taglib/asf/asffile.cpp @@ -409,7 +409,7 @@ void ASF::File::FilePrivate::HeaderExtensionObject::parse(ASF::File *file, unsig ByteVector ASF::File::FilePrivate::HeaderExtensionObject::render(ASF::File *file) { data.clear(); - for(List::ConstIterator it = objects.cbegin(); it != objects.cend(); ++it) { + for(auto it = objects.cbegin(); it != objects.cend(); ++it) { data.append((*it)->render(file)); } data = ByteVector("\x11\xD2\xD3\xAB\xBA\xA9\xcf\x11\x8E\xE6\x00\xC0\x0C\x20\x53\x65\x06\x00", 18) + ByteVector::fromUInt(data.size(), false) + data; @@ -439,7 +439,7 @@ void ASF::File::FilePrivate::CodecListObject::parse(ASF::File *file, unsigned in if(pos >= data.size()) break; - const CodecType type = static_cast(data.toUShort(pos, false)); + const auto type = static_cast(data.toUShort(pos, false)); pos += 2; int nameLength = data.toUShort(pos, false); @@ -572,7 +572,7 @@ bool ASF::File::save() const AttributeListMap allAttributes = d->tag->attributeListMap(); - for(AttributeListMap::ConstIterator it = allAttributes.begin(); it != allAttributes.end(); ++it) { + for(auto it = allAttributes.begin(); it != allAttributes.end(); ++it) { const String &name = it->first; const AttributeList &attributes = it->second; @@ -580,7 +580,7 @@ bool ASF::File::save() bool inExtendedContentDescriptionObject = false; bool inMetadataObject = false; - for(AttributeList::ConstIterator jt = attributes.begin(); jt != attributes.end(); ++jt) { + for(auto jt = attributes.begin(); jt != attributes.end(); ++jt) { const Attribute &attribute = *jt; const bool largeValue = (attribute.dataSize() > 65535); @@ -601,7 +601,7 @@ bool ASF::File::save() } ByteVector data; - for(List::ConstIterator it = d->objects.cbegin(); it != d->objects.cend(); ++it) { + for(auto it = d->objects.cbegin(); it != d->objects.cend(); ++it) { data.append((*it)->render(this)); } diff --git a/taglib/asf/asftag.cpp b/taglib/asf/asftag.cpp index 22148f7e..c116eae5 100644 --- a/taglib/asf/asftag.cpp +++ b/taglib/asf/asftag.cpp @@ -287,11 +287,11 @@ PropertyMap ASF::Tag::properties() const props["COMMENT"] = d->comment; } - ASF::AttributeListMap::ConstIterator it = d->attributeListMap.cbegin(); + auto it = d->attributeListMap.cbegin(); for(; it != d->attributeListMap.cend(); ++it) { const String key = translateKey(it->first); if(!key.isEmpty()) { - AttributeList::ConstIterator it2 = it->second.begin(); + auto it2 = it->second.begin(); for(; it2 != it->second.end(); ++it2) { if(key == "TRACKNUMBER") { if(it2->type() == ASF::Attribute::DWordType) @@ -313,7 +313,7 @@ PropertyMap ASF::Tag::properties() const void ASF::Tag::removeUnsupportedProperties(const StringList &props) { - StringList::ConstIterator it = props.begin(); + auto it = props.begin(); for(; it != props.end(); ++it) d->attributeListMap.erase(*it); } @@ -328,7 +328,7 @@ PropertyMap ASF::Tag::setProperties(const PropertyMap &props) } const PropertyMap origProps = properties(); - PropertyMap::ConstIterator it = origProps.begin(); + auto it = origProps.begin(); for(; it != origProps.end(); ++it) { if(!props.contains(it->first) || props[it->first].isEmpty()) { if(it->first == "TITLE") { @@ -355,7 +355,7 @@ PropertyMap ASF::Tag::setProperties(const PropertyMap &props) if(reverseKeyMap.contains(it->first)) { String name = reverseKeyMap[it->first]; removeItem(name); - StringList::ConstIterator it2 = it->second.begin(); + auto it2 = it->second.begin(); for(; it2 != it->second.end(); ++it2) { addAttribute(name, *it2); } diff --git a/taglib/fileref.cpp b/taglib/fileref.cpp index 35e03eeb..44fe1250 100644 --- a/taglib/fileref.cpp +++ b/taglib/fileref.cpp @@ -74,7 +74,7 @@ namespace if(::strlen(fileName) == 0) return nullptr; #endif - ResolverList::ConstIterator it = fileTypeResolvers.cbegin(); + auto it = fileTypeResolvers.cbegin(); for(; it != fileTypeResolvers.cend(); ++it) { File *file = (*it)->createFile(fileName, readAudioProperties, audioPropertiesStyle); if(file) @@ -87,9 +87,9 @@ namespace File *detectByResolvers(IOStream* stream, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle) { - for(ResolverList::ConstIterator it = fileTypeResolvers.cbegin(); + for(auto it = fileTypeResolvers.cbegin(); it != fileTypeResolvers.cend(); ++it) { - if(const FileRef::StreamTypeResolver *streamResolver = + if(auto streamResolver = dynamic_cast(*it)) { if(File *file = streamResolver->createFileFromStream( stream, readAudioProperties, audioPropertiesStyle)) diff --git a/taglib/flac/flacfile.cpp b/taglib/flac/flacfile.cpp index efd1159a..990a2276 100644 --- a/taglib/flac/flacfile.cpp +++ b/taglib/flac/flacfile.cpp @@ -189,7 +189,7 @@ bool FLAC::File::save() MetadataBlock *commentBlock = new UnknownMetadataBlock(MetadataBlock::VorbisComment, d->xiphCommentData); - for(BlockIterator it = d->blocks.begin(); it != d->blocks.end();) { + for(auto it = d->blocks.begin(); it != d->blocks.end();) { if((*it)->code() == MetadataBlock::VorbisComment) { // Remove the old Vorbis Comment block delete *it; @@ -209,7 +209,7 @@ bool FLAC::File::save() // Render data for the metadata blocks ByteVector data; - for(BlockConstIterator it = d->blocks.cbegin(); it != d->blocks.cend(); ++it) { + for(auto it = d->blocks.cbegin(); it != d->blocks.cend(); ++it) { ByteVector blockData = (*it)->render(); ByteVector blockHeader = ByteVector::fromUInt(blockData.size()); blockHeader[0] = (*it)->code(); @@ -333,8 +333,8 @@ Ogg::XiphComment *FLAC::File::xiphComment(bool create) List FLAC::File::pictureList() { List pictures; - for(BlockConstIterator it = d->blocks.cbegin(); it != d->blocks.cend(); ++it) { - Picture *picture = dynamic_cast(*it); + for(auto it = d->blocks.cbegin(); it != d->blocks.cend(); ++it) { + auto picture = dynamic_cast(*it); if(picture) { pictures.append(picture); } @@ -349,7 +349,7 @@ void FLAC::File::addPicture(Picture *picture) void FLAC::File::removePicture(Picture *picture, bool del) { - BlockIterator it = d->blocks.find(picture); + auto it = d->blocks.find(picture); if(it != d->blocks.end()) d->blocks.erase(it); @@ -359,7 +359,7 @@ void FLAC::File::removePicture(Picture *picture, bool del) void FLAC::File::removePictures() { - for(BlockIterator it = d->blocks.begin(); it != d->blocks.end(); ) { + for(auto it = d->blocks.begin(); it != d->blocks.end(); ) { if(dynamic_cast(*it)) { delete *it; it = d->blocks.erase(it); @@ -538,7 +538,7 @@ void FLAC::File::scan() } } else if(blockType == MetadataBlock::Picture) { - FLAC::Picture *picture = new FLAC::Picture(); + auto picture = new FLAC::Picture(); if(picture->parse(data)) { block = picture; } diff --git a/taglib/it/itfile.cpp b/taglib/it/itfile.cpp index 81f7a60f..4b84fa46 100644 --- a/taglib/it/itfile.cpp +++ b/taglib/it/itfile.cpp @@ -152,7 +152,7 @@ bool IT::File::save() if(!readU16L(special)) return false; - unsigned long fileSize = static_cast(File::length()); + auto fileSize = static_cast(File::length()); if(special & Properties::MessageAttached) { seek(54); if(!readU16L(messageLength) || !readU32L(messageOffset)) diff --git a/taglib/mod/modtag.cpp b/taglib/mod/modtag.cpp index 1c8bff2c..96f3bf99 100644 --- a/taglib/mod/modtag.cpp +++ b/taglib/mod/modtag.cpp @@ -163,7 +163,7 @@ PropertyMap Mod::Tag::setProperties(const PropertyMap &origProps) // 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. - for(StringList::ConstIterator it = oneValueSet.cbegin(); it != oneValueSet.cend(); ++it) { + for(auto it = oneValueSet.cbegin(); it != oneValueSet.cend(); ++it) { if(properties[*it].size() == 1) properties.erase(*it); else diff --git a/taglib/mp4/mp4atom.cpp b/taglib/mp4/mp4atom.cpp index ec9250e6..3ae2fb40 100644 --- a/taglib/mp4/mp4atom.cpp +++ b/taglib/mp4/mp4atom.cpp @@ -117,7 +117,7 @@ MP4::Atom::Atom(File *file) file->seek(8, File::Current); } while(file->tell() < offset + length) { - MP4::Atom *child = new MP4::Atom(file); + auto child = new MP4::Atom(file); children.append(child); if(child->length == 0) return; @@ -139,7 +139,7 @@ MP4::Atom::find(const char *name1, const char *name2, const char *name3, const c if(name1 == nullptr) { return this; } - for(AtomList::ConstIterator it = children.cbegin(); it != children.cend(); ++it) { + for(auto it = children.cbegin(); it != children.cend(); ++it) { if((*it)->name == name1) { return (*it)->find(name2, name3, name4); } @@ -151,7 +151,7 @@ MP4::AtomList MP4::Atom::findall(const char *name, bool recursive) { MP4::AtomList result; - for(AtomList::ConstIterator it = children.cbegin(); it != children.cend(); ++it) { + for(auto it = children.cbegin(); it != children.cend(); ++it) { if((*it)->name == name) { result.append(*it); } @@ -169,7 +169,7 @@ MP4::Atom::path(MP4::AtomList &path, const char *name1, const char *name2, const if(name1 == nullptr) { return true; } - for(AtomList::ConstIterator it = children.cbegin(); it != children.cend(); ++it) { + for(auto it = children.cbegin(); it != children.cend(); ++it) { if((*it)->name == name1) { return (*it)->path(path, name2, name3); } @@ -185,7 +185,7 @@ MP4::Atoms::Atoms(File *file) offset_t end = file->tell(); file->seek(0); while(file->tell() + 8 <= end) { - MP4::Atom *atom = new MP4::Atom(file); + auto atom = new MP4::Atom(file); atoms.append(atom); if (atom->length == 0) break; @@ -199,7 +199,7 @@ MP4::Atoms::~Atoms() MP4::Atom * MP4::Atoms::find(const char *name1, const char *name2, const char *name3, const char *name4) { - for(AtomList::ConstIterator it = atoms.cbegin(); it != atoms.cend(); ++it) { + for(auto it = atoms.cbegin(); it != atoms.cend(); ++it) { if((*it)->name == name1) { return (*it)->find(name2, name3, name4); } @@ -211,7 +211,7 @@ MP4::AtomList MP4::Atoms::path(const char *name1, const char *name2, const char *name3, const char *name4) { MP4::AtomList path; - for(AtomList::ConstIterator it = atoms.cbegin(); it != atoms.cend(); ++it) { + for(auto it = atoms.cbegin(); it != atoms.cend(); ++it) { if((*it)->name == name1) { if(!(*it)->path(path, name2, name3, name4)) { path.clear(); diff --git a/taglib/mp4/mp4file.cpp b/taglib/mp4/mp4file.cpp index 37a9a365..968c487f 100644 --- a/taglib/mp4/mp4file.cpp +++ b/taglib/mp4/mp4file.cpp @@ -38,7 +38,7 @@ namespace { bool checkValid(const MP4::AtomList &list) { - for(MP4::AtomList::ConstIterator it = list.begin(); it != list.end(); ++it) { + for(auto it = list.begin(); it != list.end(); ++it) { if((*it)->length == 0) return false; diff --git a/taglib/mp4/mp4properties.cpp b/taglib/mp4/mp4properties.cpp index 823987fb..b93ae117 100644 --- a/taglib/mp4/mp4properties.cpp +++ b/taglib/mp4/mp4properties.cpp @@ -37,7 +37,7 @@ namespace long long calculateMdatLength(const MP4::AtomList &list) { long long totalLength = 0; - for(MP4::AtomList::ConstIterator it = list.begin(); it != list.end(); ++it) { + for(auto it = list.begin(); it != list.end(); ++it) { offset_t length = (*it)->length; if(length == 0) return 0; // for safety, see checkValid() in mp4file.cpp @@ -148,7 +148,7 @@ MP4::Properties::read(File *file, Atoms *atoms) ByteVector data; const MP4::AtomList trakList = moov->findall("trak"); - for(MP4::AtomList::ConstIterator it = trakList.begin(); it != trakList.end(); ++it) { + for(auto it = trakList.begin(); it != trakList.end(); ++it) { trak = *it; MP4::Atom *hdlr = trak->find("mdia", "hdlr"); if(!hdlr) { diff --git a/taglib/mp4/mp4tag.cpp b/taglib/mp4/mp4tag.cpp index 08564fdc..63e044e5 100644 --- a/taglib/mp4/mp4tag.cpp +++ b/taglib/mp4/mp4tag.cpp @@ -61,7 +61,7 @@ MP4::Tag::Tag(TagLib::File *file, MP4::Atoms *atoms) : return; } - for(AtomList::ConstIterator it = ilst->children.cbegin(); it != ilst->children.cend(); ++it) { + for(auto it = ilst->children.cbegin(); it != ilst->children.cend(); ++it) { MP4::Atom *atom = *it; file->seek(atom->offset + 8); if(atom->name == "----") { @@ -166,7 +166,7 @@ MP4::Tag::parseData(const MP4::Atom *atom, int expectedFlags, bool freeForm) { const AtomDataList data = parseData2(atom, expectedFlags, freeForm); ByteVectorList result; - for(AtomDataList::ConstIterator it = data.begin(); it != data.end(); ++it) { + for(auto it = data.begin(); it != data.end(); ++it) { result.append(it->data); } return result; @@ -247,7 +247,7 @@ MP4::Tag::parseText(const MP4::Atom *atom, int expectedFlags) const ByteVectorList data = parseData(atom, expectedFlags); if(!data.isEmpty()) { StringList value; - for(ByteVectorList::ConstIterator it = data.begin(); it != data.end(); ++it) { + for(auto it = data.begin(); it != data.end(); ++it) { value.append(String(*it, String::UTF8)); } addItem(atom->name, value); @@ -259,7 +259,7 @@ MP4::Tag::parseFreeForm(const MP4::Atom *atom) { const AtomDataList data = parseData2(atom, -1, true); if(data.size() > 2) { - AtomDataList::ConstIterator itBegin = data.begin(); + auto itBegin = data.begin(); String name = "----:"; name += String((itBegin++)->data, String::UTF8); // data[0].data @@ -268,7 +268,7 @@ MP4::Tag::parseFreeForm(const MP4::Atom *atom) AtomDataType type = itBegin->type; // data[2].type - for(AtomDataList::ConstIterator it = itBegin; it != data.end(); ++it) { + for(auto it = itBegin; it != data.end(); ++it) { if(it->type != type) { debug("MP4: We currently don't support values with multiple types"); break; @@ -276,7 +276,7 @@ MP4::Tag::parseFreeForm(const MP4::Atom *atom) } if(type == TypeUTF8) { StringList value; - for(AtomDataList::ConstIterator it = itBegin; it != data.end(); ++it) { + for(auto it = itBegin; it != data.end(); ++it) { value.append(String(it->data, String::UTF8)); } Item item(value); @@ -285,7 +285,7 @@ MP4::Tag::parseFreeForm(const MP4::Atom *atom) } else { ByteVectorList value; - for(AtomDataList::ConstIterator it = itBegin; it != data.end(); ++it) { + for(auto it = itBegin; it != data.end(); ++it) { value.append(it->data); } Item item(value); @@ -347,7 +347,7 @@ ByteVector MP4::Tag::renderData(const ByteVector &name, int flags, const ByteVectorList &data) const { ByteVector result; - for(ByteVectorList::ConstIterator it = data.begin(); it != data.end(); ++it) { + for(auto it = data.begin(); it != data.end(); ++it) { result.append(renderAtom("data", ByteVector::fromUInt(flags) + ByteVector(4, '\0') + *it)); } return renderAtom(name, result); @@ -419,7 +419,7 @@ MP4::Tag::renderText(const ByteVector &name, const MP4::Item &item, int flags) c { ByteVectorList data; const StringList value = item.toStringList(); - for(StringList::ConstIterator it = value.begin(); it != value.end(); ++it) { + for(auto it = value.begin(); it != value.end(); ++it) { data.append(it->data(String::UTF8)); } return renderData(name, flags, data); @@ -430,7 +430,7 @@ MP4::Tag::renderCovr(const ByteVector &name, const MP4::Item &item) const { ByteVector data; const MP4::CoverArtList value = item.toCoverArtList(); - for(MP4::CoverArtList::ConstIterator it = value.begin(); it != value.end(); ++it) { + for(auto it = value.begin(); it != value.end(); ++it) { data.append(renderAtom("data", ByteVector::fromUInt(it->format()) + ByteVector(4, '\0') + it->data())); } @@ -459,13 +459,13 @@ MP4::Tag::renderFreeForm(const String &name, const MP4::Item &item) const } if(type == TypeUTF8) { const StringList value = item.toStringList(); - for(StringList::ConstIterator it = value.begin(); it != value.end(); ++it) { + for(auto it = value.begin(); it != value.end(); ++it) { data.append(renderAtom("data", ByteVector::fromUInt(type) + ByteVector(4, '\0') + it->data(String::UTF8))); } } else { const ByteVectorList value = item.toByteVectorList(); - for(ByteVectorList::ConstIterator it = value.begin(); it != value.end(); ++it) { + for(auto it = value.begin(); it != value.end(); ++it) { data.append(renderAtom("data", ByteVector::fromUInt(type) + ByteVector(4, '\0') + *it)); } } @@ -476,7 +476,7 @@ bool MP4::Tag::save() { ByteVector data; - for(MP4::ItemMap::ConstIterator it = d->items.cbegin(); it != d->items.cend(); ++it) { + for(auto it = d->items.cbegin(); it != d->items.cend(); ++it) { const String name = it->first; if(name.startsWith("----")) { data.append(renderFreeForm(name, it->second)); @@ -560,10 +560,10 @@ MP4::Tag::updateParents(const AtomList &path, offset_t delta, int ignore) if(static_cast(path.size()) <= ignore) return; - AtomList::ConstIterator itEnd = path.end(); + auto itEnd = path.end(); std::advance(itEnd, 0 - ignore); - for(AtomList::ConstIterator it = path.begin(); it != itEnd; ++it) { + for(auto it = path.begin(); it != itEnd; ++it) { d->file->seek((*it)->offset); long size = d->file->readBlock(4).toUInt(); // 64-bit @@ -588,7 +588,7 @@ MP4::Tag::updateOffsets(offset_t delta, offset_t offset) MP4::Atom *moov = d->atoms->find("moov"); if(moov) { const MP4::AtomList stco = moov->findall("stco", true); - for(MP4::AtomList::ConstIterator it = stco.begin(); it != stco.end(); ++it) { + for(auto it = stco.begin(); it != stco.end(); ++it) { MP4::Atom *atom = *it; if(atom->offset > offset) { atom->offset += delta; @@ -599,7 +599,7 @@ MP4::Tag::updateOffsets(offset_t delta, offset_t offset) d->file->seek(atom->offset + 16); unsigned int pos = 4; while(count--) { - offset_t o = static_cast(data.toUInt(pos)); + auto o = static_cast(data.toUInt(pos)); if(o > offset) { o += delta; } @@ -609,7 +609,7 @@ MP4::Tag::updateOffsets(offset_t delta, offset_t offset) } const MP4::AtomList co64 = moov->findall("co64", true); - for(MP4::AtomList::ConstIterator it = co64.begin(); it != co64.end(); ++it) { + for(auto it = co64.begin(); it != co64.end(); ++it) { MP4::Atom *atom = *it; if(atom->offset > offset) { atom->offset += delta; @@ -633,7 +633,7 @@ MP4::Tag::updateOffsets(offset_t delta, offset_t offset) MP4::Atom *moof = d->atoms->find("moof"); if(moof) { const MP4::AtomList tfhd = moof->findall("tfhd", true); - for(MP4::AtomList::ConstIterator it = tfhd.begin(); it != tfhd.end(); ++it) { + for(auto it = tfhd.begin(); it != tfhd.end(); ++it) { MP4::Atom *atom = *it; if(atom->offset > offset) { atom->offset += delta; @@ -682,18 +682,18 @@ MP4::Tag::saveNew(ByteVector data) void MP4::Tag::saveExisting(ByteVector data, const AtomList &path) { - AtomList::ConstIterator it = path.end(); + auto it = path.end(); MP4::Atom *ilst = *(--it); offset_t offset = ilst->offset; offset_t length = ilst->length; MP4::Atom *meta = *(--it); - AtomList::ConstIterator index = meta->children.cfind(ilst); + auto index = meta->children.cfind(ilst); // check if there is an atom before 'ilst', and possibly use it as padding if(index != meta->children.cbegin()) { - AtomList::ConstIterator prevIndex = index; + auto prevIndex = index; prevIndex--; MP4::Atom *prev = *prevIndex; if(prev->name == "free") { @@ -702,7 +702,7 @@ MP4::Tag::saveExisting(ByteVector data, const AtomList &path) } } // check if there is an atom after 'ilst', and possibly use it as padding - AtomList::ConstIterator nextIndex = index; + auto nextIndex = index; nextIndex++; if(nextIndex != meta->children.cend()) { MP4::Atom *next = *nextIndex; @@ -733,7 +733,7 @@ MP4::Tag::saveExisting(ByteVector data, const AtomList &path) // Strip meta if data is empty, only the case when called from strip(). MP4::Atom *udta = *(--it); AtomList &udtaChildren = udta->children; - AtomList::Iterator metaIt = udtaChildren.find(meta); + auto metaIt = udtaChildren.find(meta); if(metaIt != udtaChildren.end()) { offset = meta->offset; delta = - meta->length; @@ -986,7 +986,7 @@ namespace PropertyMap MP4::Tag::properties() const { PropertyMap props; - for(MP4::ItemMap::ConstIterator it = d->items.cbegin(); it != d->items.cend(); ++it) { + for(auto it = d->items.cbegin(); it != d->items.cend(); ++it) { const String key = translateKey(it->first); if(!key.isEmpty()) { if(key == "TRACKNUMBER" || key == "DISCNUMBER") { @@ -1018,7 +1018,7 @@ PropertyMap MP4::Tag::properties() const void MP4::Tag::removeUnsupportedProperties(const StringList &props) { - for(StringList::ConstIterator it = props.begin(); it != props.end(); ++it) + for(auto it = props.begin(); it != props.end(); ++it) d->items.erase(*it); } @@ -1032,14 +1032,14 @@ PropertyMap MP4::Tag::setProperties(const PropertyMap &props) } const PropertyMap origProps = properties(); - for(PropertyMap::ConstIterator it = origProps.begin(); it != origProps.end(); ++it) { + for(auto it = origProps.begin(); it != origProps.end(); ++it) { if(!props.contains(it->first) || props[it->first].isEmpty()) { d->items.erase(reverseKeyMap[it->first]); } } PropertyMap ignoredProps; - for(PropertyMap::ConstIterator it = props.begin(); it != props.end(); ++it) { + for(auto it = props.begin(); it != props.end(); ++it) { if(reverseKeyMap.contains(it->first)) { String name = reverseKeyMap[it->first]; if((it->first == "TRACKNUMBER" || it->first == "DISCNUMBER") && !it->second.isEmpty()) { diff --git a/taglib/mpeg/id3v2/frames/attachedpictureframe.cpp b/taglib/mpeg/id3v2/frames/attachedpictureframe.cpp index cd0297cb..931b522a 100644 --- a/taglib/mpeg/id3v2/frames/attachedpictureframe.cpp +++ b/taglib/mpeg/id3v2/frames/attachedpictureframe.cpp @@ -219,7 +219,7 @@ AttachedPictureFrameV22::AttachedPictureFrameV22(const ByteVector &data, Header parseFields(fieldData(data)); // now set the v2.4 header - Frame::Header *newHeader = new Frame::Header("APIC"); + auto newHeader = new Frame::Header("APIC"); newHeader->setFrameSize(h->frameSize()); setHeader(newHeader, true); } diff --git a/taglib/mpeg/id3v2/frames/chapterframe.cpp b/taglib/mpeg/id3v2/frames/chapterframe.cpp index e8477684..d5164470 100644 --- a/taglib/mpeg/id3v2/frames/chapterframe.cpp +++ b/taglib/mpeg/id3v2/frames/chapterframe.cpp @@ -85,7 +85,7 @@ ChapterFrame::ChapterFrame(const ByteVector &elementID, d->startOffset = startOffset; d->endOffset = endOffset; - for(FrameList::ConstIterator it = embeddedFrames.begin(); + for(auto it = embeddedFrames.begin(); it != embeddedFrames.end(); ++it) addEmbeddedFrame(*it); } @@ -172,7 +172,7 @@ void ChapterFrame::addEmbeddedFrame(Frame *frame) void ChapterFrame::removeEmbeddedFrame(Frame *frame, bool del) { // remove the frame from the frame list - FrameList::Iterator it = d->embeddedFrameList.find(frame); + auto it = d->embeddedFrameList.find(frame); d->embeddedFrameList.erase(it); // ...and from the frame list map @@ -187,7 +187,7 @@ void ChapterFrame::removeEmbeddedFrame(Frame *frame, bool del) void ChapterFrame::removeEmbeddedFrames(const ByteVector &id) { const FrameList l = d->embeddedFrameListMap[id]; - for(FrameList::ConstIterator it = l.begin(); it != l.end(); ++it) + for(auto it = l.begin(); it != l.end(); ++it) removeEmbeddedFrame(*it, true); } @@ -205,7 +205,7 @@ String ChapterFrame::toString() const if(!d->embeddedFrameList.isEmpty()) { StringList frameIDs; - for(FrameList::ConstIterator it = d->embeddedFrameList.cbegin(); + for(auto it = d->embeddedFrameList.cbegin(); it != d->embeddedFrameList.cend(); ++it) frameIDs.append((*it)->frameID()); s += ", sub-frames: [ " + frameIDs.toString(", ") + " ]"; @@ -227,11 +227,11 @@ ChapterFrame *ChapterFrame::findByElementID(const ID3v2::Tag *tag, const ByteVec { ID3v2::FrameList comments = tag->frameList("CHAP"); - for(ID3v2::FrameList::ConstIterator it = comments.cbegin(); + for(auto it = comments.cbegin(); it != comments.cend(); ++it) { - ChapterFrame *frame = dynamic_cast(*it); + auto frame = dynamic_cast(*it); if(frame && frame->elementID() == eID) return frame; } @@ -294,7 +294,7 @@ ByteVector ChapterFrame::renderFields() const data.append(ByteVector::fromUInt(d->startOffset, true)); data.append(ByteVector::fromUInt(d->endOffset, true)); const FrameList l = d->embeddedFrameList; - for(FrameList::ConstIterator it = l.begin(); it != l.end(); ++it) { + for(auto it = l.begin(); it != l.end(); ++it) { (*it)->header()->setVersion(header()->version()); data.append((*it)->render()); } diff --git a/taglib/mpeg/id3v2/frames/commentsframe.cpp b/taglib/mpeg/id3v2/frames/commentsframe.cpp index 1e3af40f..eb7e8c2f 100644 --- a/taglib/mpeg/id3v2/frames/commentsframe.cpp +++ b/taglib/mpeg/id3v2/frames/commentsframe.cpp @@ -127,11 +127,11 @@ CommentsFrame *CommentsFrame::findByDescription(const ID3v2::Tag *tag, const Str { const ID3v2::FrameList comments = tag->frameList("COMM"); - for(ID3v2::FrameList::ConstIterator it = comments.begin(); + for(auto it = comments.begin(); it != comments.end(); ++it) { - CommentsFrame *frame = dynamic_cast(*it); + auto frame = dynamic_cast(*it); if(frame && frame->description() == d) return frame; } diff --git a/taglib/mpeg/id3v2/frames/eventtimingcodesframe.cpp b/taglib/mpeg/id3v2/frames/eventtimingcodesframe.cpp index 062ea46c..11909e29 100644 --- a/taglib/mpeg/id3v2/frames/eventtimingcodesframe.cpp +++ b/taglib/mpeg/id3v2/frames/eventtimingcodesframe.cpp @@ -109,7 +109,7 @@ void EventTimingCodesFrame::parseFields(const ByteVector &data) int pos = 1; d->synchedEvents.clear(); while(pos + 4 < end) { - EventType type = static_cast(static_cast(data[pos++])); + auto type = static_cast(static_cast(data[pos++])); unsigned int time = data.toUInt(pos, true); pos += 4; d->synchedEvents.append(SynchedEvent(time, type)); @@ -121,7 +121,7 @@ ByteVector EventTimingCodesFrame::renderFields() const ByteVector v; v.append(static_cast(d->timestampFormat)); - for(SynchedEventList::ConstIterator it = d->synchedEvents.cbegin(); + for(auto it = d->synchedEvents.cbegin(); it != d->synchedEvents.cend(); ++it) { const SynchedEvent &entry = *it; diff --git a/taglib/mpeg/id3v2/frames/relativevolumeframe.cpp b/taglib/mpeg/id3v2/frames/relativevolumeframe.cpp index 3fed352f..5447b46b 100644 --- a/taglib/mpeg/id3v2/frames/relativevolumeframe.cpp +++ b/taglib/mpeg/id3v2/frames/relativevolumeframe.cpp @@ -78,7 +78,7 @@ List RelativeVolumeFrame::channels() const { List l; - Map::ConstIterator it = d->channels.cbegin(); + auto it = d->channels.cbegin(); for(; it != d->channels.cend(); ++it) l.append((*it).first); @@ -138,7 +138,7 @@ void RelativeVolumeFrame::parseFields(const ByteVector &data) while(pos <= static_cast(data.size()) - 4) { - ChannelType type = static_cast(data[pos]); + auto type = static_cast(data[pos]); pos += 1; ChannelData &channel = d->channels[type]; @@ -162,7 +162,7 @@ ByteVector RelativeVolumeFrame::renderFields() const data.append(d->identification.data(String::Latin1)); data.append(textDelimiter(String::Latin1)); - Map::ConstIterator it = d->channels.cbegin(); + auto it = d->channels.cbegin(); for(; it != d->channels.cend(); ++it) { ChannelType type = (*it).first; diff --git a/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.cpp b/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.cpp index 0c80f1fa..0b3a7fde 100644 --- a/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.cpp +++ b/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.cpp @@ -206,7 +206,7 @@ ByteVector SynchronizedLyricsFrame::renderFields() const String::Type encoding = d->textEncoding; encoding = checkTextEncoding(d->description, encoding); - for(SynchedTextList::ConstIterator it = d->synchedText.cbegin(); + for(auto it = d->synchedText.cbegin(); it != d->synchedText.cend(); ++it) { encoding = checkTextEncoding(it->text, encoding); @@ -218,7 +218,7 @@ ByteVector SynchronizedLyricsFrame::renderFields() const v.append(static_cast(d->type)); v.append(d->description.data(encoding)); v.append(textDelimiter(encoding)); - for(SynchedTextList::ConstIterator it = d->synchedText.cbegin(); + for(auto it = d->synchedText.cbegin(); it != d->synchedText.cend(); ++it) { const SynchedText &entry = *it; diff --git a/taglib/mpeg/id3v2/frames/tableofcontentsframe.cpp b/taglib/mpeg/id3v2/frames/tableofcontentsframe.cpp index e1a46419..d267b268 100644 --- a/taglib/mpeg/id3v2/frames/tableofcontentsframe.cpp +++ b/taglib/mpeg/id3v2/frames/tableofcontentsframe.cpp @@ -69,7 +69,7 @@ namespace { ByteVectorList &strip(ByteVectorList &l) { - for(ByteVectorList::Iterator it = l.begin(); it != l.end(); ++it) + for(auto it = l.begin(); it != l.end(); ++it) { strip(*it); } @@ -99,7 +99,7 @@ TableOfContentsFrame::TableOfContentsFrame(const ByteVector &elementID, strip(d->elementID); d->childElements = children; - for(FrameList::ConstIterator it = embeddedFrames.begin(); it != embeddedFrames.end(); ++it) + for(auto it = embeddedFrames.begin(); it != embeddedFrames.end(); ++it) addEmbeddedFrame(*it); } @@ -163,7 +163,7 @@ void TableOfContentsFrame::addChildElement(const ByteVector &cE) void TableOfContentsFrame::removeChildElement(const ByteVector &cE) { - ByteVectorList::Iterator it = d->childElements.find(cE); + auto it = d->childElements.find(cE); if(it == d->childElements.end()) it = d->childElements.find(cE + ByteVector("\0")); @@ -196,7 +196,7 @@ void TableOfContentsFrame::addEmbeddedFrame(Frame *frame) void TableOfContentsFrame::removeEmbeddedFrame(Frame *frame, bool del) { // remove the frame from the frame list - FrameList::Iterator it = d->embeddedFrameList.find(frame); + auto it = d->embeddedFrameList.find(frame); if(it != d->embeddedFrameList.end()) d->embeddedFrameList.erase(it); @@ -214,7 +214,7 @@ void TableOfContentsFrame::removeEmbeddedFrame(Frame *frame, bool del) void TableOfContentsFrame::removeEmbeddedFrames(const ByteVector &id) { const FrameList l = d->embeddedFrameListMap[id]; - for(FrameList::ConstIterator it = l.begin(); it != l.end(); ++it) + for(auto it = l.begin(); it != l.end(); ++it) removeEmbeddedFrame(*it, true); } @@ -230,7 +230,7 @@ String TableOfContentsFrame::toString() const if(!d->embeddedFrameList.isEmpty()) { StringList frameIDs; - for(FrameList::ConstIterator it = d->embeddedFrameList.cbegin(); + for(auto it = d->embeddedFrameList.cbegin(); it != d->embeddedFrameList.cend(); ++it) frameIDs.append((*it)->frameID()); s += ", sub-frames: [ " + frameIDs.toString(", ") + " ]"; @@ -253,11 +253,11 @@ TableOfContentsFrame *TableOfContentsFrame::findByElementID(const ID3v2::Tag *ta { const ID3v2::FrameList tablesOfContents = tag->frameList("CTOC"); - for(ID3v2::FrameList::ConstIterator it = tablesOfContents.begin(); + for(auto it = tablesOfContents.begin(); it != tablesOfContents.end(); ++it) { - TableOfContentsFrame *frame = dynamic_cast(*it); + auto frame = dynamic_cast(*it); if(frame && frame->elementID() == eID) return frame; } @@ -269,11 +269,11 @@ TableOfContentsFrame *TableOfContentsFrame::findTopLevel(const ID3v2::Tag *tag) { const ID3v2::FrameList tablesOfContents = tag->frameList("CTOC"); - for(ID3v2::FrameList::ConstIterator it = tablesOfContents.begin(); + for(auto it = tablesOfContents.begin(); it != tablesOfContents.end(); ++it) { - TableOfContentsFrame *frame = dynamic_cast(*it); + auto frame = dynamic_cast(*it); if(frame && frame->isTopLevel()) return frame; } @@ -337,14 +337,14 @@ ByteVector TableOfContentsFrame::renderFields() const flags += 1; data.append(flags); data.append(static_cast(entryCount())); - ByteVectorList::ConstIterator it = d->childElements.cbegin(); + auto it = d->childElements.cbegin(); while(it != d->childElements.cend()) { data.append(*it); data.append('\0'); it++; } const FrameList l = d->embeddedFrameList; - for(FrameList::ConstIterator it = l.begin(); it != l.end(); ++it) { + for(auto it = l.begin(); it != l.end(); ++it) { (*it)->header()->setVersion(header()->version()); data.append((*it)->render()); } diff --git a/taglib/mpeg/id3v2/frames/textidentificationframe.cpp b/taglib/mpeg/id3v2/frames/textidentificationframe.cpp index 7757b2f8..ed9362e4 100644 --- a/taglib/mpeg/id3v2/frames/textidentificationframe.cpp +++ b/taglib/mpeg/id3v2/frames/textidentificationframe.cpp @@ -60,9 +60,9 @@ TextIdentificationFrame::TextIdentificationFrame(const ByteVector &data) : TextIdentificationFrame *TextIdentificationFrame::createTIPLFrame(const PropertyMap &properties) // static { - TextIdentificationFrame *frame = new TextIdentificationFrame("TIPL"); + auto frame = new TextIdentificationFrame("TIPL"); StringList l; - for(PropertyMap::ConstIterator it = properties.begin(); it != properties.end(); ++it){ + for(auto it = properties.begin(); it != properties.end(); ++it){ const String role = involvedPeopleMap()[it->first]; if(role.isEmpty()) // should not happen continue; @@ -75,9 +75,9 @@ TextIdentificationFrame *TextIdentificationFrame::createTIPLFrame(const Property TextIdentificationFrame *TextIdentificationFrame::createTMCLFrame(const PropertyMap &properties) // static { - TextIdentificationFrame *frame = new TextIdentificationFrame("TMCL"); + auto frame = new TextIdentificationFrame("TMCL"); StringList l; - for(PropertyMap::ConstIterator it = properties.begin(); it != properties.end(); ++it){ + for(auto it = properties.begin(); it != properties.end(); ++it){ if(!it->first.startsWith(instrumentPrefix)) // should not happen continue; l.append(it->first.substr(instrumentPrefix.size())); @@ -161,14 +161,14 @@ PropertyMap TextIdentificationFrame::asProperties() const if(tagName == "GENRE") { // Special case: Support ID3v1-style genre numbers. They are not officially supported in // ID3v2, however it seems that still a lot of programs use them. - for(StringList::Iterator it = values.begin(); it != values.end(); ++it) { + for(auto it = values.begin(); it != values.end(); ++it) { bool ok = false; int test = it->toInt(&ok); // test if the genre value is an integer if(ok) *it = ID3v1::genre(test); } } else if(tagName == "DATE") { - for(StringList::Iterator it = values.begin(); it != values.end(); ++it) { + for(auto it = values.begin(); it != values.end(); ++it) { // ID3v2 specifies ISO8601 timestamps which contain a 'T' as separator between date and time. // Since this is unusual in other formats, the T is removed. int tpos = it->find("T"); @@ -219,7 +219,7 @@ void TextIdentificationFrame::parseFields(const ByteVector &data) // type is the same specified for this frame unsigned short firstBom = 0; - for(ByteVectorList::ConstIterator it = l.begin(); it != l.end(); it++) { + for(auto it = l.begin(); it != l.end(); it++) { if(!it->isEmpty() || (it == l.begin() && frameID() == "TXXX")) { if(d->textEncoding == String::Latin1) { d->fieldList.append(Tag::latin1StringHandler()->parse(*it)); @@ -256,7 +256,7 @@ ByteVector TextIdentificationFrame::renderFields() const v.append(static_cast(encoding)); - for(StringList::ConstIterator it = d->fieldList.cbegin(); it != d->fieldList.cend(); it++) { + for(auto it = d->fieldList.cbegin(); it != d->fieldList.cend(); it++) { // Since the field list is null delimited, if this is not the first // element in the list, append the appropriate delimiter for this @@ -291,7 +291,7 @@ PropertyMap TextIdentificationFrame::makeTIPLProperties() const return map; } const StringList l = fieldList(); - for(StringList::ConstIterator it = l.begin(); it != l.end(); ++it) { + for(auto it = l.begin(); it != l.end(); ++it) { bool found = false; for(size_t i = 0; i < involvedPeopleSize; ++i) if(*it == involvedPeople[i].first) { @@ -318,7 +318,7 @@ PropertyMap TextIdentificationFrame::makeTMCLProperties() const return map; } const StringList l = fieldList(); - for(StringList::ConstIterator it = l.begin(); it != l.end(); ++it) { + for(auto it = l.begin(); it != l.end(); ++it) { String instrument = it->upper(); if(instrument.isEmpty()) { // instrument is not a valid key -> frame unsupported @@ -364,7 +364,7 @@ String UserTextIdentificationFrame::toString() const { // first entry is the description itself, drop from values list StringList l = fieldList(); - for(StringList::Iterator it = l.begin(); it != l.end(); ++it) { + for(auto it = l.begin(); it != l.end(); ++it) { l.erase(it); break; } @@ -418,7 +418,7 @@ PropertyMap UserTextIdentificationFrame::asProperties() const PropertyMap map; String tagName = txxxToKey(description()); const StringList v = fieldList(); - for(StringList::ConstIterator it = v.begin(); it != v.end(); ++it) + for(auto it = v.begin(); it != v.end(); ++it) if(it != v.begin()) map.insert(tagName, *it); return map; @@ -428,8 +428,8 @@ UserTextIdentificationFrame *UserTextIdentificationFrame::find( ID3v2::Tag *tag, const String &description) // static { const FrameList l = tag->frameList("TXXX"); - for(FrameList::ConstIterator it = l.begin(); it != l.end(); ++it) { - UserTextIdentificationFrame *f = dynamic_cast(*it); + for(auto it = l.begin(); it != l.end(); ++it) { + auto f = dynamic_cast(*it); if(f && f->description() == description) return f; } diff --git a/taglib/mpeg/id3v2/frames/uniquefileidentifierframe.cpp b/taglib/mpeg/id3v2/frames/uniquefileidentifierframe.cpp index 69526991..d8a55cf8 100644 --- a/taglib/mpeg/id3v2/frames/uniquefileidentifierframe.cpp +++ b/taglib/mpeg/id3v2/frames/uniquefileidentifierframe.cpp @@ -105,11 +105,11 @@ UniqueFileIdentifierFrame *UniqueFileIdentifierFrame::findByOwner(const ID3v2::T { const ID3v2::FrameList comments = tag->frameList("UFID"); - for(ID3v2::FrameList::ConstIterator it = comments.begin(); + for(auto it = comments.begin(); it != comments.end(); ++it) { - UniqueFileIdentifierFrame *frame = dynamic_cast(*it); + auto frame = dynamic_cast(*it); if(frame && frame->owner() == o) return frame; } diff --git a/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.cpp b/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.cpp index fc002528..b3f3e6da 100644 --- a/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.cpp +++ b/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.cpp @@ -129,8 +129,8 @@ UnsynchronizedLyricsFrame *UnsynchronizedLyricsFrame::findByDescription(const ID { const ID3v2::FrameList lyrics = tag->frameList("USLT"); - for(ID3v2::FrameList::ConstIterator it = lyrics.begin(); it != lyrics.end(); ++it){ - UnsynchronizedLyricsFrame *frame = dynamic_cast(*it); + for(auto it = lyrics.begin(); it != lyrics.end(); ++it){ + auto frame = dynamic_cast(*it); if(frame && frame->description() == d) return frame; } diff --git a/taglib/mpeg/id3v2/frames/urllinkframe.cpp b/taglib/mpeg/id3v2/frames/urllinkframe.cpp index 5fa3c743..a7700a72 100644 --- a/taglib/mpeg/id3v2/frames/urllinkframe.cpp +++ b/taglib/mpeg/id3v2/frames/urllinkframe.cpp @@ -180,8 +180,8 @@ PropertyMap UserUrlLinkFrame::asProperties() const UserUrlLinkFrame *UserUrlLinkFrame::find(ID3v2::Tag *tag, const String &description) // static { const FrameList l = tag->frameList("WXXX"); - for(FrameList::ConstIterator it = l.begin(); it != l.end(); ++it) { - UserUrlLinkFrame *f = dynamic_cast(*it); + for(auto it = l.begin(); it != l.end(); ++it) { + auto f = dynamic_cast(*it); if(f && f->description() == description) return f; } diff --git a/taglib/mpeg/id3v2/id3v2frame.cpp b/taglib/mpeg/id3v2/id3v2frame.cpp index b57ce928..046196e0 100644 --- a/taglib/mpeg/id3v2/id3v2frame.cpp +++ b/taglib/mpeg/id3v2/id3v2frame.cpp @@ -67,7 +67,7 @@ namespace if(frameID.size() != 4) return false; - for(ByteVector::ConstIterator it = frameID.begin(); it != frameID.end(); it++) { + for(auto it = frameID.begin(); it != frameID.end(); it++) { if( (*it < 'A' || *it > 'Z') && (*it < '0' || *it > '9') ) { return false; } @@ -108,11 +108,11 @@ Frame *Frame::createTextualFrame(const String &key, const StringList &values) // if(!frameID.isEmpty()) { // Apple proprietary WFED (Podcast URL), MVNM (Movement Name), MVIN (Movement Number), GRP1 (Grouping) are in fact text frames. if(frameID[0] == 'T' || frameID == "WFED" || frameID == "MVNM" || frameID == "MVIN" || frameID == "GRP1"){ // text frame - TextIdentificationFrame *frame = new TextIdentificationFrame(frameID, String::UTF8); + auto frame = new TextIdentificationFrame(frameID, String::UTF8); frame->setText(values); return frame; } if((frameID[0] == 'W') && (values.size() == 1)){ // URL frame (not WXXX); support only one value - UrlLinkFrame* frame = new UrlLinkFrame(frameID); + auto frame = new UrlLinkFrame(frameID); frame->setUrl(values.front()); return frame; } if(frameID == "PCST") { @@ -120,27 +120,27 @@ Frame *Frame::createTextualFrame(const String &key, const StringList &values) // } } if(key == "MUSICBRAINZ_TRACKID" && values.size() == 1) { - UniqueFileIdentifierFrame *frame = new UniqueFileIdentifierFrame("http://musicbrainz.org", values.front().data(String::UTF8)); + auto frame = new UniqueFileIdentifierFrame("http://musicbrainz.org", values.front().data(String::UTF8)); return frame; } // now we check if it's one of the "special" cases: // -LYRICS: depending on the number of values, use USLT or TXXX (with description=LYRICS) if((key == "LYRICS" || key.startsWith(lyricsPrefix)) && values.size() == 1){ - UnsynchronizedLyricsFrame *frame = new UnsynchronizedLyricsFrame(String::UTF8); + auto frame = new UnsynchronizedLyricsFrame(String::UTF8); frame->setDescription(key == "LYRICS" ? key : key.substr(lyricsPrefix.size())); frame->setText(values.front()); return frame; } // -URL: depending on the number of values, use WXXX or TXXX (with description=URL) if((key == "URL" || key.startsWith(urlPrefix)) && values.size() == 1){ - UserUrlLinkFrame *frame = new UserUrlLinkFrame(String::UTF8); + auto frame = new UserUrlLinkFrame(String::UTF8); frame->setDescription(key == "URL" ? key : key.substr(urlPrefix.size())); frame->setUrl(values.front()); return frame; } // -COMMENT: depending on the number of values, use COMM or TXXX (with description=COMMENT) if((key == "COMMENT" || key.startsWith(commentPrefix)) && values.size() == 1){ - CommentsFrame *frame = new CommentsFrame(String::UTF8); + auto frame = new CommentsFrame(String::UTF8); if (key != "COMMENT"){ frame->setDescription(key.substr(commentPrefix.size())); } @@ -290,7 +290,7 @@ String::Type Frame::checkTextEncoding(const StringList &fields, String::Type enc if(encoding != String::Latin1) return encoding; - for(StringList::ConstIterator it = fields.begin(); it != fields.end(); ++it) { + for(auto it = fields.begin(); it != fields.end(); ++it) { if(!(*it).isLatin1()) { if(header()->version() == 4) { debug("Frame::checkEncoding() -- Rendering using UTF8."); @@ -475,7 +475,7 @@ void Frame::splitProperties(const PropertyMap &original, PropertyMap &singleFram singleFrameProperties.clear(); tiplProperties.clear(); tmclProperties.clear(); - for(PropertyMap::ConstIterator it = original.begin(); it != original.end(); ++it) { + for(auto it = original.begin(); it != original.end(); ++it) { if(TextIdentificationFrame::involvedPeopleMap().contains(it->first)) tiplProperties.insert(it->first, it->second); else if(it->first.startsWith(TextIdentificationFrame::instrumentPrefix)) diff --git a/taglib/mpeg/id3v2/id3v2framefactory.cpp b/taglib/mpeg/id3v2/id3v2framefactory.cpp index 75baf4cd..6c194c1b 100644 --- a/taglib/mpeg/id3v2/id3v2framefactory.cpp +++ b/taglib/mpeg/id3v2/id3v2framefactory.cpp @@ -58,7 +58,7 @@ namespace StringList fields = frame->fieldList(); StringList newfields; - for(StringList::ConstIterator it = fields.cbegin(); it != fields.cend(); ++it) { + for(auto it = fields.cbegin(); it != fields.cend(); ++it) { String s = *it; int offset = 0; int end = 0; @@ -119,7 +119,7 @@ Frame *FrameFactory::createFrame(const ByteVector &origData, const Header *tagHe { ByteVector data = origData; unsigned int version = tagHeader->majorVersion(); - Frame::Header *header = new Frame::Header(data, version); + auto header = new Frame::Header(data, version); ByteVector frameID = header->frameID(); // A quick sanity check -- make sure that the frameID is 4 uppercase Latin1 @@ -144,7 +144,7 @@ Frame *FrameFactory::createFrame(const ByteVector &origData, const Header *tagHe } #endif - for(ByteVector::ConstIterator it = frameID.cbegin(); it != frameID.cend(); it++) { + for(auto it = frameID.cbegin(); it != frameID.cend(); it++) { if( (*it < 'A' || *it > 'Z') && (*it < '0' || *it > '9') ) { delete header; return nullptr; @@ -206,7 +206,7 @@ Frame *FrameFactory::createFrame(const ByteVector &origData, const Header *tagHe // Comments (frames 4.10) if(frameID == "COMM") { - CommentsFrame *f = new CommentsFrame(data, header); + auto f = new CommentsFrame(data, header); d->setTextEncoding(f); return f; } @@ -214,7 +214,7 @@ Frame *FrameFactory::createFrame(const ByteVector &origData, const Header *tagHe // Attached Picture (frames 4.14) if(frameID == "APIC") { - AttachedPictureFrame *f = new AttachedPictureFrame(data, header); + auto f = new AttachedPictureFrame(data, header); d->setTextEncoding(f); return f; } @@ -240,7 +240,7 @@ Frame *FrameFactory::createFrame(const ByteVector &origData, const Header *tagHe // General Encapsulated Object (frames 4.15) if(frameID == "GEOB") { - GeneralEncapsulatedObjectFrame *f = new GeneralEncapsulatedObjectFrame(data, header); + auto f = new GeneralEncapsulatedObjectFrame(data, header); d->setTextEncoding(f); return f; } @@ -251,7 +251,7 @@ Frame *FrameFactory::createFrame(const ByteVector &origData, const Header *tagHe if(frameID != "WXXX") { return new UrlLinkFrame(data, header); } - UserUrlLinkFrame *f = new UserUrlLinkFrame(data, header); + auto f = new UserUrlLinkFrame(data, header); d->setTextEncoding(f); return f; } @@ -259,7 +259,7 @@ Frame *FrameFactory::createFrame(const ByteVector &origData, const Header *tagHe // Unsynchronized lyric/text transcription (frames 4.8) if(frameID == "USLT") { - UnsynchronizedLyricsFrame *f = new UnsynchronizedLyricsFrame(data, header); + auto f = new UnsynchronizedLyricsFrame(data, header); if(d->useDefaultEncoding) f->setTextEncoding(d->defaultEncoding); return f; @@ -268,7 +268,7 @@ Frame *FrameFactory::createFrame(const ByteVector &origData, const Header *tagHe // Synchronized lyrics/text (frames 4.9) if(frameID == "SYLT") { - SynchronizedLyricsFrame *f = new SynchronizedLyricsFrame(data, header); + auto f = new SynchronizedLyricsFrame(data, header); if(d->useDefaultEncoding) f->setTextEncoding(d->defaultEncoding); return f; @@ -292,7 +292,7 @@ Frame *FrameFactory::createFrame(const ByteVector &origData, const Header *tagHe // Ownership (frames 4.22) if(frameID == "OWNE") { - OwnershipFrame *f = new OwnershipFrame(data, header); + auto f = new OwnershipFrame(data, header); d->setTextEncoding(f); return f; } diff --git a/taglib/mpeg/id3v2/id3v2header.cpp b/taglib/mpeg/id3v2/id3v2header.cpp index 6b8684fc..bf5af676 100644 --- a/taglib/mpeg/id3v2/id3v2header.cpp +++ b/taglib/mpeg/id3v2/id3v2header.cpp @@ -210,7 +210,7 @@ void Header::parse(const ByteVector &data) return; } - for(ByteVector::ConstIterator it = sizeData.begin(); it != sizeData.end(); it++) { + for(auto it = sizeData.begin(); it != sizeData.end(); it++) { if(static_cast(*it) >= 128) { d->tagSize = 0; debug("TagLib::ID3v2::Header::parse() - One of the size bytes in the id3v2 header was greater than the allowed 128."); diff --git a/taglib/mpeg/id3v2/id3v2synchdata.cpp b/taglib/mpeg/id3v2/id3v2synchdata.cpp index ba848dec..54080cb5 100644 --- a/taglib/mpeg/id3v2/id3v2synchdata.cpp +++ b/taglib/mpeg/id3v2/id3v2synchdata.cpp @@ -83,8 +83,8 @@ ByteVector SynchData::decode(const ByteVector &data) ByteVector result(data.size()); - ByteVector::ConstIterator src = data.begin(); - ByteVector::Iterator dst = result.begin(); + auto src = data.begin(); + auto dst = result.begin(); while(src < data.end() - 1) { *dst++ = *src++; diff --git a/taglib/mpeg/id3v2/id3v2tag.cpp b/taglib/mpeg/id3v2/id3v2tag.cpp index 87b48e0a..b9b5339e 100644 --- a/taglib/mpeg/id3v2/id3v2tag.cpp +++ b/taglib/mpeg/id3v2/id3v2tag.cpp @@ -168,9 +168,9 @@ String ID3v2::Tag::comment() const if(comments.isEmpty()) return String(); - for(FrameList::ConstIterator it = comments.begin(); it != comments.end(); ++it) + for(auto it = comments.begin(); it != comments.end(); ++it) { - CommentsFrame *frame = dynamic_cast(*it); + auto frame = dynamic_cast(*it); if(frame && frame->description().isEmpty()) return (*it)->toString(); @@ -191,7 +191,7 @@ String ID3v2::Tag::genre() const return String(); } - TextIdentificationFrame *f = dynamic_cast(tconFrames.front()); + auto f = dynamic_cast(tconFrames.front()); if(!f) { return String(); @@ -207,7 +207,7 @@ String ID3v2::Tag::genre() const StringList genres; - for(StringList::Iterator it = fields.begin(); it != fields.end(); ++it) { + for(auto it = fields.begin(); it != fields.end(); ++it) { if((*it).isEmpty()) continue; @@ -264,8 +264,8 @@ void ID3v2::Tag::setComment(const String &s) const FrameList &comments = d->frameListMap["COMM"]; if(!comments.isEmpty()) { - for(FrameList::ConstIterator it = comments.begin(); it != comments.end(); ++it) { - CommentsFrame *frame = dynamic_cast(*it); + for(auto it = comments.begin(); it != comments.end(); ++it) { + auto frame = dynamic_cast(*it); if(frame && frame->description().isEmpty()) { (*it)->setText(s); return; @@ -276,7 +276,7 @@ void ID3v2::Tag::setComment(const String &s) return; } - CommentsFrame *f = new CommentsFrame(d->factory->defaultTextEncoding()); + auto f = new CommentsFrame(d->factory->defaultTextEncoding()); addFrame(f); f->setText(s); } @@ -364,7 +364,7 @@ void ID3v2::Tag::addFrame(Frame *frame) void ID3v2::Tag::removeFrame(Frame *frame, bool del) { // remove the frame from the frame list - FrameList::Iterator it = d->frameList.find(frame); + auto it = d->frameList.find(frame); d->frameList.erase(it); // ...and from the frame list map @@ -379,14 +379,14 @@ void ID3v2::Tag::removeFrame(Frame *frame, bool del) void ID3v2::Tag::removeFrames(const ByteVector &id) { const FrameList l = d->frameListMap[id]; - for(FrameList::ConstIterator it = l.begin(); it != l.end(); ++it) + for(auto it = l.begin(); it != l.end(); ++it) removeFrame(*it, true); } PropertyMap ID3v2::Tag::properties() const { PropertyMap properties; - for(FrameList::ConstIterator it = frameList().begin(); it != frameList().end(); ++it) { + for(auto it = frameList().begin(); it != frameList().end(); ++it) { PropertyMap props = (*it)->asProperties(); properties.merge(props); } @@ -395,7 +395,7 @@ PropertyMap ID3v2::Tag::properties() const void ID3v2::Tag::removeUnsupportedProperties(const StringList &properties) { - for(StringList::ConstIterator it = properties.begin(); it != properties.end(); ++it){ + for(auto it = properties.begin(); it != properties.end(); ++it){ if(it->startsWith("UNKNOWN/")) { String frameID = it->substr(String("UNKNOWN/").size()); if(frameID.size() != 4) @@ -403,7 +403,7 @@ void ID3v2::Tag::removeUnsupportedProperties(const StringList &properties) ByteVector id = frameID.data(String::Latin1); // delete all unknown frames of given type const FrameList l = frameList(id); - for(FrameList::ConstIterator fit = l.begin(); fit != l.end(); fit++) + for(auto fit = l.begin(); fit != l.end(); fit++) if (dynamic_cast(*fit) != nullptr) removeFrame(*fit); } @@ -442,8 +442,8 @@ PropertyMap ID3v2::Tag::setProperties(const PropertyMap &origProps) PropertyMap tiplProperties; PropertyMap tmclProperties; Frame::splitProperties(origProps, properties, tiplProperties, tmclProperties); - for(FrameListMap::ConstIterator it = frameListMap().begin(); it != frameListMap().end(); ++it){ - for(FrameList::ConstIterator lit = it->second.begin(); lit != it->second.end(); ++lit){ + for(auto it = frameListMap().begin(); it != frameListMap().end(); ++it){ + for(auto lit = it->second.begin(); lit != it->second.end(); ++lit){ PropertyMap frameProperties = (*lit)->asProperties(); if(it->first == "TIPL") { if (tiplProperties != frameProperties) @@ -461,7 +461,7 @@ PropertyMap ID3v2::Tag::setProperties(const PropertyMap &origProps) properties.erase(frameProperties); } } - for(FrameList::ConstIterator it = framesToDelete.cbegin(); it != framesToDelete.cend(); ++it) + for(auto it = framesToDelete.cbegin(); it != framesToDelete.cend(); ++it) removeFrame(*it); // now create remaining frames: @@ -472,7 +472,7 @@ PropertyMap ID3v2::Tag::setProperties(const PropertyMap &origProps) if(!tmclProperties.isEmpty()) addFrame(TextIdentificationFrame::createTMCLFrame(tmclProperties)); // now create the "one key per frame" frames - for(PropertyMap::ConstIterator it = properties.cbegin(); it != properties.cend(); ++it) + for(auto it = properties.cbegin(); it != properties.cend(); ++it) addFrame(Frame::createTextualFrame(it->first, it->second)); return PropertyMap(); // ID3 implements the complete PropertyMap interface, so an empty map is returned } @@ -502,7 +502,7 @@ void ID3v2::Tag::downgradeFrames(FrameList *frames, FrameList *newFrames) const ID3v2::TextIdentificationFrame *frameTMCL = nullptr; ID3v2::TextIdentificationFrame *frameTCON = nullptr; - for(FrameList::ConstIterator it = d->frameList.cbegin(); it != d->frameList.cend(); it++) { + for(auto it = d->frameList.cbegin(); it != d->frameList.cend(); it++) { ID3v2::Frame *frame = *it; ByteVector frameID = frame->header()->frameID(); @@ -531,7 +531,7 @@ void ID3v2::Tag::downgradeFrames(FrameList *frames, FrameList *newFrames) const String content = frameTDOR->toString(); if(content.size() >= 4) { - ID3v2::TextIdentificationFrame *frameTORY = + auto frameTORY = new ID3v2::TextIdentificationFrame("TORY", String::Latin1); frameTORY->setText(content.substr(0, 4)); frames->append(frameTORY); @@ -542,19 +542,19 @@ void ID3v2::Tag::downgradeFrames(FrameList *frames, FrameList *newFrames) const if(frameTDRC) { String content = frameTDRC->toString(); if(content.size() >= 4) { - ID3v2::TextIdentificationFrame *frameTYER = + auto frameTYER = new ID3v2::TextIdentificationFrame("TYER", String::Latin1); frameTYER->setText(content.substr(0, 4)); frames->append(frameTYER); newFrames->append(frameTYER); if(content.size() >= 10 && content[4] == '-' && content[7] == '-') { - ID3v2::TextIdentificationFrame *frameTDAT = + auto frameTDAT = new ID3v2::TextIdentificationFrame("TDAT", String::Latin1); frameTDAT->setText(content.substr(8, 2) + content.substr(5, 2)); frames->append(frameTDAT); newFrames->append(frameTDAT); if(content.size() >= 16 && content[10] == 'T' && content[13] == ':') { - ID3v2::TextIdentificationFrame *frameTIME = + auto frameTIME = new ID3v2::TextIdentificationFrame("TIME", String::Latin1); frameTIME->setText(content.substr(11, 2) + content.substr(14, 2)); frames->append(frameTIME); @@ -565,7 +565,7 @@ void ID3v2::Tag::downgradeFrames(FrameList *frames, FrameList *newFrames) const } if(frameTIPL || frameTMCL) { - ID3v2::TextIdentificationFrame *frameIPLS = + auto frameIPLS = new ID3v2::TextIdentificationFrame("IPLS", String::Latin1); StringList people; @@ -599,7 +599,7 @@ void ID3v2::Tag::downgradeFrames(FrameList *frames, FrameList *newFrames) const // If there are multiple genres, add them as multiple references to ID3v1 // genres if such a reference exists. The first genre for which no ID3v1 // genre number exists can be finally added as a refinement. - for(StringList::ConstIterator it = genres.begin(); it != genres.end(); ++it) { + for(auto it = genres.begin(); it != genres.end(); ++it) { bool ok = false; int number = it->toInt(&ok); if((ok && number >= 0 && number <= 255) || *it == "RX" || *it == "CR") @@ -647,7 +647,7 @@ ByteVector ID3v2::Tag::render(Version version) const // Loop through the frames rendering them and adding them to the tagData. - for(FrameList::ConstIterator it = frameList.cbegin(); it != frameList.cend(); it++) { + for(auto it = frameList.cbegin(); it != frameList.cend(); it++) { (*it)->header()->setVersion(version == v3 ? 3 : 4); if((*it)->header()->frameID().size() != 4) { debug("An ID3v2 frame of unsupported or unknown type \'" @@ -833,7 +833,7 @@ void ID3v2::Tag::setTextFrame(const ByteVector &id, const String &value) d->frameListMap[id].front()->setText(value); else { const String::Type encoding = d->factory->defaultTextEncoding(); - TextIdentificationFrame *f = new TextIdentificationFrame(id, encoding); + auto f = new TextIdentificationFrame(id, encoding); addFrame(f); f->setText(value); } diff --git a/taglib/ogg/oggfile.cpp b/taglib/ogg/oggfile.cpp index 7cd69504..0ec0eaa9 100644 --- a/taglib/ogg/oggfile.cpp +++ b/taglib/ogg/oggfile.cpp @@ -95,7 +95,7 @@ ByteVector Ogg::File::packet(unsigned int i) // Look for the first page in which the requested packet starts. - List::ConstIterator it = d->pages.cbegin(); + auto it = d->pages.cbegin(); while((*it)->containsPacket(i) == Page::DoesNotContainPacket) ++it; @@ -213,7 +213,7 @@ bool Ogg::File::readPages(unsigned int i) // Read the next page and add it to the page list. - Page *nextPage = new Page(this, offset); + auto nextPage = new Page(this, offset); if(!nextPage->header()->isValid()) { delete nextPage; return false; @@ -236,7 +236,7 @@ void Ogg::File::writePacket(unsigned int i, const ByteVector &packet) // Look for the pages where the requested packet should belong to. - List::ConstIterator it = d->pages.cbegin(); + auto it = d->pages.cbegin(); while((*it)->containsPacket(i) == Page::DoesNotContainPacket) ++it; diff --git a/taglib/ogg/oggpage.cpp b/taglib/ogg/oggpage.cpp index 8b05cd46..ce76d474 100644 --- a/taglib/ogg/oggpage.cpp +++ b/taglib/ogg/oggpage.cpp @@ -90,7 +90,7 @@ unsigned int pageChecksum(const ByteVector &data) }; unsigned int sum = 0; - for(ByteVector::ConstIterator it = data.begin(); it != data.end(); ++it) + for(auto it = data.begin(); it != data.end(); ++it) sum = (sum << 8) ^ crcTable[((sum >> 24) & 0xff) ^ static_cast(*it)]; return sum; } @@ -213,7 +213,7 @@ ByteVectorList Ogg::Page::packets() const const List packetSizes = d->header.packetSizes(); - List::ConstIterator it = packetSizes.begin(); + auto it = packetSizes.begin(); for(; it != packetSizes.end(); ++it) l.append(d->file->readBlock(*it)); } @@ -243,7 +243,7 @@ ByteVector Ogg::Page::render() const debug("Ogg::Page::render() -- this page is empty!"); } else { - ByteVectorList::ConstIterator it = d->packets.cbegin(); + auto it = d->packets.cbegin(); for(; it != d->packets.cend(); ++it) data.append(*it); } @@ -276,7 +276,7 @@ List Ogg::Page::paginate(const ByteVectorList &packets, if(strategy != Repaginate) { size_t tableSize = 0; - for(ByteVectorList::ConstIterator it = packets.begin(); it != packets.end(); ++it) + for(auto it = packets.begin(); it != packets.end(); ++it) tableSize += it->size() / 255 + 1; if(tableSize > 255) @@ -291,7 +291,7 @@ List Ogg::Page::paginate(const ByteVectorList &packets, int pageIndex = firstPage; - for(ByteVectorList::ConstIterator it = packets.begin(); it != packets.end(); ++it) { + for(auto it = packets.begin(); it != packets.end(); ++it) { const bool lastPacketInList = (it == --packets.end()); @@ -356,7 +356,7 @@ Ogg::Page::Page(const ByteVectorList &packets, ByteVector data; List packetSizes; - for(ByteVectorList::ConstIterator it = packets.begin(); it != packets.end(); ++it) { + for(auto it = packets.begin(); it != packets.end(); ++it) { packetSizes.append((*it).size()); data.append(*it); } diff --git a/taglib/ogg/oggpageheader.cpp b/taglib/ogg/oggpageheader.cpp index 76753e81..983f7be6 100644 --- a/taglib/ogg/oggpageheader.cpp +++ b/taglib/ogg/oggpageheader.cpp @@ -295,7 +295,7 @@ ByteVector Ogg::PageHeader::lacingValues() const { ByteVector data; - for(List::ConstIterator it = d->packetSizes.cbegin(); it != d->packetSizes.cend(); ++it) { + for(auto it = d->packetSizes.cbegin(); it != d->packetSizes.cend(); ++it) { // The size of a packet in an Ogg page is indicated by a series of "lacing // values" where the sum of the values is the packet size in bytes. Each of diff --git a/taglib/ogg/xiphcomment.cpp b/taglib/ogg/xiphcomment.cpp index e03d1ed3..ebeac2cc 100644 --- a/taglib/ogg/xiphcomment.cpp +++ b/taglib/ogg/xiphcomment.cpp @@ -191,7 +191,7 @@ void Ogg::XiphComment::setTrack(unsigned int i) bool Ogg::XiphComment::isEmpty() const { - for(FieldConstIterator it = d->fieldListMap.cbegin(); it != d->fieldListMap.cend(); ++it) { + for(auto it = d->fieldListMap.cbegin(); it != d->fieldListMap.cend(); ++it) { if(!(*it).second.isEmpty()) return false; } @@ -203,7 +203,7 @@ unsigned int Ogg::XiphComment::fieldCount() const { unsigned int count = 0; - for(FieldConstIterator it = d->fieldListMap.cbegin(); it != d->fieldListMap.cend(); ++it) + for(auto it = d->fieldListMap.cbegin(); it != d->fieldListMap.cend(); ++it) count += (*it).second.size(); count += d->pictureList.size(); @@ -225,16 +225,16 @@ PropertyMap Ogg::XiphComment::setProperties(const PropertyMap &properties) { // check which keys are to be deleted StringList toRemove; - for(FieldConstIterator it = d->fieldListMap.cbegin(); it != d->fieldListMap.cend(); ++it) + for(auto it = d->fieldListMap.cbegin(); it != d->fieldListMap.cend(); ++it) if (!properties.contains(it->first)) toRemove.append(it->first); - for(StringList::ConstIterator it = toRemove.cbegin(); it != toRemove.cend(); ++it) + for(auto it = toRemove.cbegin(); it != toRemove.cend(); ++it) removeFields(*it); // now go through keys in \a properties and check that the values match those in the xiph comment PropertyMap invalid; - PropertyMap::ConstIterator it = properties.begin(); + auto it = properties.begin(); for(; it != properties.end(); ++it) { if(!checkKey(it->first)) @@ -246,7 +246,7 @@ PropertyMap Ogg::XiphComment::setProperties(const PropertyMap &properties) removeFields(it->first); else { // replace all strings in the list for the tag - StringList::ConstIterator valueIterator = sl.begin(); + auto valueIterator = sl.begin(); addField(it->first, *valueIterator, true); ++valueIterator; for(; valueIterator != sl.end(); ++valueIterator) @@ -301,7 +301,7 @@ void Ogg::XiphComment::removeFields(const String &key) void Ogg::XiphComment::removeFields(const String &key, const String &value) { StringList &fields = d->fieldListMap[key.upper()]; - for(StringList::Iterator it = fields.begin(); it != fields.end(); ) { + for(auto it = fields.begin(); it != fields.end(); ) { if(*it == value) it = fields.erase(it); else @@ -321,7 +321,7 @@ bool Ogg::XiphComment::contains(const String &key) const void Ogg::XiphComment::removePicture(FLAC::Picture *picture, bool del) { - PictureIterator it = d->pictureList.find(picture); + auto it = d->pictureList.find(picture); if(it != d->pictureList.end()) d->pictureList.erase(it); @@ -366,7 +366,7 @@ ByteVector Ogg::XiphComment::render(bool addFramingBit) const // std::pair where the first String is the field name and // the StringList is the values associated with that field. - FieldListMap::ConstIterator it = d->fieldListMap.cbegin(); + auto it = d->fieldListMap.cbegin(); for(; it != d->fieldListMap.cend(); ++it) { // And now iterate over the values of the current list. @@ -374,7 +374,7 @@ ByteVector Ogg::XiphComment::render(bool addFramingBit) const String fieldName = (*it).first; const StringList values = (*it).second; - StringList::ConstIterator valuesIt = values.begin(); + auto valuesIt = values.begin(); for(; valuesIt != values.end(); ++valuesIt) { ByteVector fieldData = fieldName.data(String::UTF8); fieldData.append('='); @@ -385,7 +385,7 @@ ByteVector Ogg::XiphComment::render(bool addFramingBit) const } } - for(PictureConstIterator it = d->pictureList.cbegin(); it != d->pictureList.cend(); ++it) { + for(auto it = d->pictureList.cbegin(); it != d->pictureList.cend(); ++it) { ByteVector picture = (*it)->render().toBase64(); data.append(ByteVector::fromUInt(picture.size() + 23, false)); data.append("METADATA_BLOCK_PICTURE="); @@ -472,7 +472,7 @@ void Ogg::XiphComment::parse(const ByteVector &data) // Decode FLAC Picture - FLAC::Picture * picture = new FLAC::Picture(); + auto picture = new FLAC::Picture(); if(picture->parse(picturedata)) { d->pictureList.append(picture); } @@ -485,7 +485,7 @@ void Ogg::XiphComment::parse(const ByteVector &data) // Assume it's some type of image file - FLAC::Picture * picture = new FLAC::Picture(); + auto picture = new FLAC::Picture(); picture->setData(picturedata); picture->setMimeType("image/"); picture->setType(FLAC::Picture::Other); diff --git a/taglib/riff/rifffile.cpp b/taglib/riff/rifffile.cpp index c0b6717e..a1055761 100644 --- a/taglib/riff/rifffile.cpp +++ b/taglib/riff/rifffile.cpp @@ -158,7 +158,7 @@ void RIFF::File::setChunkData(unsigned int i, const ByteVector &data) // Now update the specific chunk - std::vector::iterator it = d->chunks.begin(); + auto it = d->chunks.begin(); std::advance(it, i); const long long originalSize = static_cast(it->size) + it->padding; @@ -252,7 +252,7 @@ void RIFF::File::removeChunk(unsigned int i) return; } - std::vector::iterator it = d->chunks.begin(); + auto it = d->chunks.begin(); std::advance(it, i); const unsigned int removeSize = it->size + it->padding + 8; diff --git a/taglib/riff/riffutils.h b/taglib/riff/riffutils.h index 1c3817da..9973b044 100644 --- a/taglib/riff/riffutils.h +++ b/taglib/riff/riffutils.h @@ -44,7 +44,7 @@ namespace TagLib if(name.size() != 4) return false; - for(ByteVector::ConstIterator it = name.begin(); it != name.end(); ++it) { + for(auto it = name.begin(); it != name.end(); ++it) { const int c = static_cast(*it); if(c < 32 || 127 < c) return false; diff --git a/taglib/riff/wav/infotag.cpp b/taglib/riff/wav/infotag.cpp index 121e870e..ed131c50 100644 --- a/taglib/riff/wav/infotag.cpp +++ b/taglib/riff/wav/infotag.cpp @@ -201,7 +201,7 @@ ByteVector RIFF::Info::Tag::render() const { ByteVector data("INFO"); - FieldListMap::ConstIterator it = d->fieldListMap.cbegin(); + auto it = d->fieldListMap.cbegin(); for(; it != d->fieldListMap.cend(); ++it) { ByteVector text = stringHandler->render(it->second); if(text.isEmpty()) diff --git a/taglib/tag.cpp b/taglib/tag.cpp index 1d3832b1..c7f32f34 100644 --- a/taglib/tag.cpp +++ b/taglib/tag.cpp @@ -141,7 +141,7 @@ PropertyMap Tag::setProperties(const PropertyMap &origProps) // 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. - for(StringList::ConstIterator it = oneValueSet.cbegin(); it != oneValueSet.cend(); ++it) { + for(auto it = oneValueSet.cbegin(); it != oneValueSet.cend(); ++it) { if(properties[*it].size() == 1) properties.erase(*it); else diff --git a/taglib/toolkit/tbytevector.cpp b/taglib/toolkit/tbytevector.cpp index f409f5e2..6b5423b5 100644 --- a/taglib/toolkit/tbytevector.cpp +++ b/taglib/toolkit/tbytevector.cpp @@ -467,7 +467,7 @@ ByteVector &ByteVector::replace(char oldByte, char newByte) { detach(); - for(ByteVector::Iterator it = begin(); it != end(); ++it) { + for(auto it = begin(); it != end(); ++it) { if(*it == oldByte) *it = newByte; } @@ -868,8 +868,8 @@ ByteVector ByteVector::fromBase64(const ByteVector & input) ByteVector output(len); - const unsigned char * src = reinterpret_cast(input.data()); - unsigned char * dst = reinterpret_cast(output.data()); + auto src = reinterpret_cast(input.data()); + auto dst = reinterpret_cast(output.data()); while(4 <= len) { diff --git a/taglib/toolkit/tbytevectorlist.cpp b/taglib/toolkit/tbytevectorlist.cpp index 8b2f71e1..26c1610a 100644 --- a/taglib/toolkit/tbytevectorlist.cpp +++ b/taglib/toolkit/tbytevectorlist.cpp @@ -83,7 +83,7 @@ ByteVector ByteVectorList::toByteVector(const ByteVector &separator) const { ByteVector v; - ConstIterator it = begin(); + auto it = begin(); while(it != end()) { v.append(*it); diff --git a/taglib/toolkit/tfilestream.cpp b/taglib/toolkit/tfilestream.cpp index 3a0397b7..2df4869c 100644 --- a/taglib/toolkit/tfilestream.cpp +++ b/taglib/toolkit/tfilestream.cpp @@ -207,7 +207,7 @@ ByteVector FileStream::readBlock(size_t length) return ByteVector(); if(length > bufferSize()) { - const size_t streamLength = static_cast(FileStream::length()); + const auto streamLength = static_cast(FileStream::length()); if(length > streamLength) { length = streamLength; } @@ -288,7 +288,7 @@ void FileStream::insert(const ByteVector &data, offset_t start, size_t replace) // to overwrite. Appropriately increment the readPosition. seek(readPosition); - const unsigned int bytesRead = static_cast(readFile(d->file, aboutToOverwrite)); + const auto bytesRead = static_cast(readFile(d->file, aboutToOverwrite)); aboutToOverwrite.resize(bytesRead); readPosition += bufferLength; diff --git a/taglib/toolkit/tlist.tcc b/taglib/toolkit/tlist.tcc index c9a5c558..a56f316d 100644 --- a/taglib/toolkit/tlist.tcc +++ b/taglib/toolkit/tlist.tcc @@ -74,7 +74,7 @@ public: } void clear() { if(autoDelete) { - typename std::list::const_iterator it = list.begin(); + auto it = list.begin(); for(; it != list.end(); ++it) delete *it; } @@ -282,7 +282,7 @@ T &List::back() template T &List::operator[](unsigned int i) { - Iterator it = d->list.begin(); + auto it = d->list.begin(); std::advance(it, i); return *it; @@ -291,7 +291,7 @@ T &List::operator[](unsigned int i) template const T &List::operator[](unsigned int i) const { - ConstIterator it = d->list.begin(); + auto it = d->list.begin(); std::advance(it, i); return *it; diff --git a/taglib/toolkit/tmap.tcc b/taglib/toolkit/tmap.tcc index 0ca27c5d..1096086f 100644 --- a/taglib/toolkit/tmap.tcc +++ b/taglib/toolkit/tmap.tcc @@ -169,7 +169,7 @@ unsigned int Map::size() const template T Map::value(const Key &key, const T &defaultValue) const { - ConstIterator it = d->map.find(key); + auto it = d->map.find(key); return it != d->map.end() ? it->second : defaultValue; } diff --git a/taglib/toolkit/tpropertymap.cpp b/taglib/toolkit/tpropertymap.cpp index 072e6498..e6fef3d4 100644 --- a/taglib/toolkit/tpropertymap.cpp +++ b/taglib/toolkit/tpropertymap.cpp @@ -38,7 +38,7 @@ PropertyMap::PropertyMap(const PropertyMap &m) : SimplePropertyMap(m), unsupport PropertyMap::PropertyMap(const SimplePropertyMap &m) { - for(SimplePropertyMap::ConstIterator it = m.begin(); it != m.end(); ++it){ + for(auto it = m.begin(); it != m.end(); ++it){ String key = it->first.upper(); if(!key.isEmpty()) insert(it->first, it->second); @@ -54,7 +54,7 @@ PropertyMap::~PropertyMap() bool PropertyMap::insert(const String &key, const StringList &values) { String realKey = key.upper(); - Iterator result = SimplePropertyMap::find(realKey); + auto result = SimplePropertyMap::find(realKey); if(result == end()) SimplePropertyMap::insert(realKey, values); else @@ -87,7 +87,7 @@ bool PropertyMap::contains(const String &key) const bool PropertyMap::contains(const PropertyMap &other) const { - for(ConstIterator it = other.begin(); it != other.end(); ++it) { + for(auto it = other.begin(); it != other.end(); ++it) { if(!SimplePropertyMap::contains(it->first)) return false; if ((*this)[it->first] != it->second) @@ -104,14 +104,14 @@ PropertyMap &PropertyMap::erase(const String &key) PropertyMap &PropertyMap::erase(const PropertyMap &other) { - for(ConstIterator it = other.begin(); it != other.end(); ++it) + for(auto it = other.begin(); it != other.end(); ++it) erase(it->first); return *this; } PropertyMap &PropertyMap::merge(const PropertyMap &other) { - for(PropertyMap::ConstIterator it = other.begin(); it != other.end(); ++it) + for(auto it = other.begin(); it != other.end(); ++it) insert(it->first, it->second); unsupported.append(other.unsupported); return *this; @@ -135,13 +135,13 @@ StringList &PropertyMap::operator[](const String &key) bool PropertyMap::operator==(const PropertyMap &other) const { - for(ConstIterator it = other.begin(); it != other.end(); ++it) { - ConstIterator thisFind = find(it->first); + for(auto it = other.begin(); it != other.end(); ++it) { + auto thisFind = find(it->first); if( thisFind == end() || (thisFind->second != it->second) ) return false; } - for(ConstIterator it = begin(); it != end(); ++it) { - ConstIterator otherFind = other.find(it->first); + for(auto it = begin(); it != end(); ++it) { + auto otherFind = other.find(it->first); if( otherFind == other.end() || (otherFind->second != it->second) ) return false; } @@ -157,7 +157,7 @@ String PropertyMap::toString() const { String ret; - for(ConstIterator it = begin(); it != end(); ++it) + for(auto it = begin(); it != end(); ++it) ret += it->first+"="+it->second.toString(", ") + "\n"; if(!unsupported.isEmpty()) ret += "Unsupported Data: " + unsupported.toString(", ") + "\n"; @@ -167,7 +167,7 @@ String PropertyMap::toString() const void PropertyMap::removeEmpty() { PropertyMap m; - for(ConstIterator it = cbegin(); it != cend(); ++it) { + for(auto it = cbegin(); it != cend(); ++it) { if(!it->second.isEmpty()) m.insert(it->first, it->second); } diff --git a/taglib/toolkit/tstring.cpp b/taglib/toolkit/tstring.cpp index f064a000..6d50a2a1 100644 --- a/taglib/toolkit/tstring.cpp +++ b/taglib/toolkit/tstring.cpp @@ -432,7 +432,7 @@ ByteVector String::data(Type t) const ByteVector v(size() * 4, 0); try { - const ByteVector::Iterator dstEnd = utf8::utf16to8(begin(), end(), v.begin()); + const auto dstEnd = utf8::utf16to8(begin(), end(), v.begin()); v.resize(static_cast(dstEnd - v.begin())); } catch(const utf8::exception &e) { diff --git a/taglib/toolkit/tstringlist.cpp b/taglib/toolkit/tstringlist.cpp index 32370913..a6d3260c 100644 --- a/taglib/toolkit/tstringlist.cpp +++ b/taglib/toolkit/tstringlist.cpp @@ -72,7 +72,7 @@ StringList::StringList(const String &s) StringList::StringList(const ByteVectorList &bl, String::Type t) { - ByteVectorList::ConstIterator i = bl.begin(); + auto i = bl.begin(); for(;i != bl.end(); i++) { append(String(*i, t)); } @@ -87,8 +87,8 @@ String StringList::toString(const String &separator) const { String s; - ConstIterator it = begin(); - ConstIterator itEnd = end(); + auto it = begin(); + auto itEnd = end(); while(it != itEnd) { s += *it; diff --git a/taglib/wavpack/wavpackproperties.cpp b/taglib/wavpack/wavpackproperties.cpp index b35dd0f2..a59224b1 100644 --- a/taglib/wavpack/wavpackproperties.cpp +++ b/taglib/wavpack/wavpackproperties.cpp @@ -167,7 +167,7 @@ namespace int index = 0; while(index + 1 < blockSize) { - const unsigned char metaId = static_cast(block[index]); + const auto metaId = static_cast(block[index]); int metaBc = static_cast(block[index + 1]) << 1; index += 2; @@ -201,7 +201,7 @@ namespace // if we got DSD block, return the specified rate shift amount if(id == ID_DSD_BLOCK && (metaId & ID_UNIQUE) == ID_DSD_BLOCK && metaBc > 0) { - const unsigned char rateShift = static_cast(block[index]); + const auto rateShift = static_cast(block[index]); if(rateShift <= 31) return rateShift; } diff --git a/taglib/xm/xmfile.cpp b/taglib/xm/xmfile.cpp index 7a8ec0d8..66c4052e 100644 --- a/taglib/xm/xmfile.cpp +++ b/taglib/xm/xmfile.cpp @@ -323,7 +323,7 @@ public: unsigned int size() const override { unsigned int size = 0; - for(List::ConstIterator i = m_readers.begin(); + for(auto i = m_readers.begin(); i != m_readers.end(); ++ i) { size += (*i)->size(); } @@ -333,7 +333,7 @@ public: unsigned int read(TagLib::File &file, unsigned int limit) override { unsigned int sumcount = 0; - for(List::ConstIterator i = m_readers.cbegin(); + for(auto i = m_readers.cbegin(); limit > 0 && i != m_readers.cend(); ++ i) { unsigned int count = (*i)->read(file, limit); limit -= count; diff --git a/tests/test_bytevector.cpp b/tests/test_bytevector.cpp index 26cde765..add8980f 100644 --- a/tests/test_bytevector.cpp +++ b/tests/test_bytevector.cpp @@ -357,8 +357,8 @@ public: ByteVector v1("taglib"); ByteVector v2 = v1; - ByteVector::Iterator it1 = v1.begin(); - ByteVector::Iterator it2 = v2.begin(); + auto it1 = v1.begin(); + auto it2 = v2.begin(); CPPUNIT_ASSERT_EQUAL('t', *it1); CPPUNIT_ASSERT_EQUAL('t', *it2); @@ -371,8 +371,8 @@ public: CPPUNIT_ASSERT_EQUAL(ByteVector("taglib"), v1); CPPUNIT_ASSERT_EQUAL(ByteVector("taglIb"), v2); - ByteVector::ReverseIterator it3 = v1.rbegin(); - ByteVector::ReverseIterator it4 = v2.rbegin(); + auto it3 = v1.rbegin(); + auto it4 = v2.rbegin(); CPPUNIT_ASSERT_EQUAL('b', *it3); CPPUNIT_ASSERT_EQUAL('b', *it4); diff --git a/tests/test_flac.cpp b/tests/test_flac.cpp index d5352b3c..924fb451 100644 --- a/tests/test_flac.cpp +++ b/tests/test_flac.cpp @@ -126,7 +126,7 @@ public: List lst = f.pictureList(); CPPUNIT_ASSERT_EQUAL((unsigned int)1, lst.size()); - FLAC::Picture *newpic = new FLAC::Picture(); + auto newpic = new FLAC::Picture(); newpic->setType(FLAC::Picture::BackCover); newpic->setWidth(5); newpic->setHeight(6); @@ -175,7 +175,7 @@ public: List lst = f.pictureList(); CPPUNIT_ASSERT_EQUAL((unsigned int)1, lst.size()); - FLAC::Picture *newpic = new FLAC::Picture(); + auto newpic = new FLAC::Picture(); newpic->setType(FLAC::Picture::BackCover); newpic->setWidth(5); newpic->setHeight(6); @@ -616,7 +616,7 @@ public: CPPUNIT_ASSERT(!f.hasXiphComment()); CPPUNIT_ASSERT(f.pictureList().isEmpty()); - FLAC::Picture *pic = new FLAC::Picture; + auto pic = new FLAC::Picture; pic->setData(picData); pic->setType(FLAC::Picture::FrontCover); pic->setMimeType("image/png"); diff --git a/tests/test_flacpicture.cpp b/tests/test_flacpicture.cpp index 6613c598..ffef79fe 100644 --- a/tests/test_flacpicture.cpp +++ b/tests/test_flacpicture.cpp @@ -48,7 +48,7 @@ public: void testParse() { const unsigned char data[] = { 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x09, 0x69, 0x6D, 0x61, 0x67, 0x65, 0x2F, 0x70, 0x6E, 0x67, 0x00, 0x00, 0x00, 0x08, 0x41, 0x20, 0x70, 0x69, 0x78, 0x65, 0x6C, 0x2E, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x96, 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x02, 0x00, 0x00, 0x00, 0x90, 0x77, 0x53, 0xDE, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0B, 0x13, 0x00, 0x00, 0x0B, 0x13, 0x01, 0x00, 0x9A, 0x9C, 0x18, 0x00, 0x00, 0x00, 0x07, 0x74, 0x49, 0x4D, 0x45, 0x07, 0xD6, 0x0B, 0x1C, 0x0A, 0x36, 0x06, 0x08, 0x44, 0x3D, 0x32, 0x00, 0x00, 0x00, 0x1D, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6F, 0x6D, 0x6D, 0x65, 0x6E, 0x74, 0x00, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x54, 0x68, 0x65, 0x20, 0x47, 0x49, 0x4D, 0x50, 0xEF, 0x64, 0x25, 0x6E, 0x00, 0x00, 0x00, 0x0C, 0x49, 0x44, 0x41, 0x54, 0x08, 0xD7, 0x63, 0xF8, 0xFF, 0xFF, 0x3F, 0x00, 0x05, 0xFE, 0x02, 0xFE, 0xDC, 0xCC, 0x59, 0xE7, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42, 0x60, 0x82 }; - const char *pdata = reinterpret_cast(data); + auto pdata = reinterpret_cast(data); FLAC::Picture pic(ByteVector(pdata, 199)); @@ -65,7 +65,7 @@ public: void testPassThrough() { const unsigned char data[] = { 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x09, 0x69, 0x6D, 0x61, 0x67, 0x65, 0x2F, 0x70, 0x6E, 0x67, 0x00, 0x00, 0x00, 0x08, 0x41, 0x20, 0x70, 0x69, 0x78, 0x65, 0x6C, 0x2E, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x96, 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x02, 0x00, 0x00, 0x00, 0x90, 0x77, 0x53, 0xDE, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0B, 0x13, 0x00, 0x00, 0x0B, 0x13, 0x01, 0x00, 0x9A, 0x9C, 0x18, 0x00, 0x00, 0x00, 0x07, 0x74, 0x49, 0x4D, 0x45, 0x07, 0xD6, 0x0B, 0x1C, 0x0A, 0x36, 0x06, 0x08, 0x44, 0x3D, 0x32, 0x00, 0x00, 0x00, 0x1D, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6F, 0x6D, 0x6D, 0x65, 0x6E, 0x74, 0x00, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x54, 0x68, 0x65, 0x20, 0x47, 0x49, 0x4D, 0x50, 0xEF, 0x64, 0x25, 0x6E, 0x00, 0x00, 0x00, 0x0C, 0x49, 0x44, 0x41, 0x54, 0x08, 0xD7, 0x63, 0xF8, 0xFF, 0xFF, 0x3F, 0x00, 0x05, 0xFE, 0x02, 0xFE, 0xDC, 0xCC, 0x59, 0xE7, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42, 0x60, 0x82 }; - const char *pdata = reinterpret_cast(data); + auto pdata = reinterpret_cast(data); FLAC::Picture pic(ByteVector(pdata, 199)); CPPUNIT_ASSERT_EQUAL(ByteVector(pdata, 199), pic.render()); @@ -74,4 +74,3 @@ public: }; CPPUNIT_TEST_SUITE_REGISTRATION(TestFLACPicture); - diff --git a/tests/test_id3v2.cpp b/tests/test_id3v2.cpp index d931f03f..4958ea1b 100644 --- a/tests/test_id3v2.cpp +++ b/tests/test_id3v2.cpp @@ -154,7 +154,7 @@ public: ScopedFileCopy copy("xing", ".mp3"); string newname = copy.fileName(); - ID3v2::TextIdentificationFrame *f + auto f = new ID3v2::TextIdentificationFrame(ByteVector("TPE1"), String::UTF8); StringList sl; sl.append("Foo"); @@ -177,8 +177,7 @@ public: { ScopedFileCopy copy("xing", ".mp3"); - ID3v2::UnsynchronizedLyricsFrame *f - = new ID3v2::UnsynchronizedLyricsFrame(String::UTF8); + auto f = new ID3v2::UnsynchronizedLyricsFrame(String::UTF8); f->setText("Foo"); MPEG::File file(copy.fileName().c_str()); @@ -302,7 +301,7 @@ public: "\x00", 14); ID3v2::Header header; header.setMajorVersion(2); - ID3v2::AttachedPictureFrame *frame = + auto frame = dynamic_cast(factory->createFrame(data, &header)); CPPUNIT_ASSERT(frame); @@ -345,7 +344,7 @@ public: "\x00", 14); ID3v2::Header header; header.setMajorVersion(2); - ID3v2::UnknownFrame *frame = + auto frame = dynamic_cast(factory->createFrame(data, &header)); CPPUNIT_ASSERT(frame); @@ -447,7 +446,7 @@ public: ScopedFileCopy copy("xing", ".mp3"); string newname = copy.fileName(); - ID3v2::PopularimeterFrame *f = new ID3v2::PopularimeterFrame(); + auto f = new ID3v2::PopularimeterFrame(); f->setEmail("email@example.com"); f->setRating(200); f->setCounter(3); @@ -926,7 +925,7 @@ public: "(22)Death Metal", 26); // Text ID3v2::Header header; header.setMajorVersion(3); - ID3v2::TextIdentificationFrame *frame = + auto frame = dynamic_cast(factory->createFrame(data, &header)); CPPUNIT_ASSERT_EQUAL((unsigned int)1, frame->fieldList().size()); CPPUNIT_ASSERT_EQUAL(String("Death Metal"), frame->fieldList()[0]); @@ -947,7 +946,7 @@ public: "(4)Eurodisco", 23); // Text ID3v2::Header header; header.setMajorVersion(3); - ID3v2::TextIdentificationFrame *frame = + auto frame = dynamic_cast(factory->createFrame(data, &header)); CPPUNIT_ASSERT_EQUAL((unsigned int)2, frame->fieldList().size()); CPPUNIT_ASSERT_EQUAL(String("4"), frame->fieldList()[0]); @@ -969,7 +968,7 @@ public: "(9)(138)Viking Metal", 31); // Text ID3v2::Header header; header.setMajorVersion(3); - ID3v2::TextIdentificationFrame *frame = + auto frame = dynamic_cast(factory->createFrame(data, &header)); CPPUNIT_ASSERT_EQUAL(3U, frame->fieldList().size()); CPPUNIT_ASSERT_EQUAL(String("9"), frame->fieldList()[0]); @@ -990,7 +989,7 @@ public: "\0" // Encoding "14\0Eurodisco", 23); // Text ID3v2::Header header; - ID3v2::TextIdentificationFrame *frame = + auto frame = dynamic_cast(factory->createFrame(data, &header)); CPPUNIT_ASSERT_EQUAL((unsigned int)2, frame->fieldList().size()); CPPUNIT_ASSERT_EQUAL(String("14"), frame->fieldList()[0]); @@ -1180,25 +1179,25 @@ public: void testPropertyInterface2() { ID3v2::Tag tag; - ID3v2::UnsynchronizedLyricsFrame *frame1 = new ID3v2::UnsynchronizedLyricsFrame(); + auto frame1 = new ID3v2::UnsynchronizedLyricsFrame(); frame1->setDescription("test"); frame1->setText("la-la-la test"); tag.addFrame(frame1); - ID3v2::UnsynchronizedLyricsFrame *frame2 = new ID3v2::UnsynchronizedLyricsFrame(); + auto frame2 = new ID3v2::UnsynchronizedLyricsFrame(); frame2->setDescription(""); frame2->setText("la-la-la nodescription"); tag.addFrame(frame2); - ID3v2::AttachedPictureFrame *frame3 = new ID3v2::AttachedPictureFrame(); + auto frame3 = new ID3v2::AttachedPictureFrame(); frame3->setDescription("test picture"); tag.addFrame(frame3); - ID3v2::TextIdentificationFrame *frame4 = new ID3v2::TextIdentificationFrame("TIPL"); + auto frame4 = new ID3v2::TextIdentificationFrame("TIPL"); frame4->setText("single value is invalid for TIPL"); tag.addFrame(frame4); - ID3v2::TextIdentificationFrame *frame5 = new ID3v2::TextIdentificationFrame("TMCL"); + auto frame5 = new ID3v2::TextIdentificationFrame("TMCL"); StringList tmclData; tmclData.append("VIOLIN"); tmclData.append("a violinist"); @@ -1207,13 +1206,13 @@ public: frame5->setText(tmclData); tag.addFrame(frame5); - ID3v2::UniqueFileIdentifierFrame *frame6 = new ID3v2::UniqueFileIdentifierFrame("http://musicbrainz.org", "152454b9-19ba-49f3-9fc9-8fc26545cf41"); + auto frame6 = new ID3v2::UniqueFileIdentifierFrame("http://musicbrainz.org", "152454b9-19ba-49f3-9fc9-8fc26545cf41"); tag.addFrame(frame6); - ID3v2::UniqueFileIdentifierFrame *frame7 = new ID3v2::UniqueFileIdentifierFrame("http://example.com", "123"); + auto frame7 = new ID3v2::UniqueFileIdentifierFrame("http://example.com", "123"); tag.addFrame(frame7); - ID3v2::UserTextIdentificationFrame *frame8 = new ID3v2::UserTextIdentificationFrame(); + auto frame8 = new ID3v2::UserTextIdentificationFrame(); frame8->setDescription("MusicBrainz Album Id"); frame8->setText("95c454a5-d7e0-4d8f-9900-db04aca98ab3"); tag.addFrame(frame8); @@ -1249,11 +1248,11 @@ public: void testPropertiesMovement() { ID3v2::Tag tag; - ID3v2::TextIdentificationFrame *frameMvnm = new ID3v2::TextIdentificationFrame("MVNM"); + auto frameMvnm = new ID3v2::TextIdentificationFrame("MVNM"); frameMvnm->setText("Movement Name"); tag.addFrame(frameMvnm); - ID3v2::TextIdentificationFrame *frameMvin = new ID3v2::TextIdentificationFrame("MVIN"); + auto frameMvin = new ID3v2::TextIdentificationFrame("MVIN"); frameMvin->setText("2/3"); tag.addFrame(frameMvin); @@ -1278,11 +1277,9 @@ public: ID3v2::FrameFactory *factory = ID3v2::FrameFactory::instance(); ID3v2::Header header; - ID3v2::TextIdentificationFrame *parsedFrameMvnm = - dynamic_cast( + auto parsedFrameMvnm = dynamic_cast( factory->createFrame(frameDataMvnm, &header)); - ID3v2::TextIdentificationFrame *parsedFrameMvin = - dynamic_cast( + auto parsedFrameMvin = dynamic_cast( factory->createFrame(frameDataMvin, &header)); CPPUNIT_ASSERT(parsedFrameMvnm); CPPUNIT_ASSERT(parsedFrameMvin); @@ -1296,7 +1293,7 @@ public: void testPropertyGrouping() { ID3v2::Tag tag; - ID3v2::TextIdentificationFrame *frameGrp1 = new ID3v2::TextIdentificationFrame("GRP1"); + auto frameGrp1 = new ID3v2::TextIdentificationFrame("GRP1"); frameGrp1->setText("Grouping"); tag.addFrame(frameGrp1); @@ -1313,8 +1310,7 @@ public: ID3v2::FrameFactory *factory = ID3v2::FrameFactory::instance(); ID3v2::Header header; - ID3v2::TextIdentificationFrame *parsedFrameGrp1 = - dynamic_cast( + auto parsedFrameGrp1 = dynamic_cast( factory->createFrame(frameDataGrp1, &header)); CPPUNIT_ASSERT(parsedFrameGrp1); CPPUNIT_ASSERT_EQUAL(String("Grouping"), parsedFrameGrp1->toString()); @@ -1414,7 +1410,7 @@ public: f1.setEndTime(5); f1.setStartOffset(2); f1.setEndOffset(3); - ID3v2::TextIdentificationFrame *eF = new ID3v2::TextIdentificationFrame("TIT2"); + auto eF = new ID3v2::TextIdentificationFrame("TIT2"); eF->setText("CH1"); f1.addEmbeddedFrame(eF); @@ -1520,7 +1516,7 @@ public: f.setIsOrdered(true); f.addChildElement(ByteVector("\x43\x00", 2)); f.addChildElement(ByteVector("\x44\x00", 2)); - ID3v2::TextIdentificationFrame *eF = new ID3v2::TextIdentificationFrame("TIT2"); + auto eF = new ID3v2::TextIdentificationFrame("TIT2"); eF->setText("TC1"); f.addEmbeddedFrame(eF); CPPUNIT_ASSERT_EQUAL( @@ -1573,11 +1569,11 @@ public: MPEG::File f(newname.c_str()); ID3v2::Tag *tag = f.ID3v2Tag(true); - ID3v2::UrlLinkFrame *frame1 = new ID3v2::UrlLinkFrame( + auto frame1 = new ID3v2::UrlLinkFrame( ByteVector("WOAF\x00\x00\x00\x01\x00\x00\x00", 11)); tag->addFrame(frame1); - ID3v2::TextIdentificationFrame *frame2 = new ID3v2::TextIdentificationFrame("TIT2"); + auto frame2 = new ID3v2::TextIdentificationFrame("TIT2"); frame2->setText("Title"); tag->addFrame(frame2); @@ -1638,12 +1634,10 @@ public: const ID3v2::FrameList &frames = tag->frameList(); CPPUNIT_ASSERT_EQUAL(130U, frames.size()); int i = 0; - for(ID3v2::FrameList::ConstIterator it = frames.begin(); it != frames.end(); - ++it, ++i) { + for(auto it = frames.begin(); it != frames.end(); ++it, ++i) { if(i > 0) { CPPUNIT_ASSERT_EQUAL(ByteVector("CHAP"), (*it)->frameID()); - const ID3v2::ChapterFrame *chapFrame = - dynamic_cast(*it); + auto chapFrame = dynamic_cast(*it); CPPUNIT_ASSERT_EQUAL(ByteVector("chapter") + ByteVector(String::number(i - 1).toCString()), chapFrame->elementID()); @@ -1653,8 +1647,7 @@ public: chapFrame->endTime()); const ID3v2::FrameList &embeddedFrames = chapFrame->embeddedFrameList(); CPPUNIT_ASSERT_EQUAL(1U, embeddedFrames.size()); - const ID3v2::TextIdentificationFrame *tit2Frame = - dynamic_cast( + auto tit2Frame = dynamic_cast( embeddedFrames.front()); CPPUNIT_ASSERT(tit2Frame); CPPUNIT_ASSERT_EQUAL(String("Marker ") + String::number(i), @@ -1662,16 +1655,14 @@ public: } else { CPPUNIT_ASSERT_EQUAL(ByteVector("CTOC"), (*it)->frameID()); - const ID3v2::TableOfContentsFrame *ctocFrame = - dynamic_cast(*it); + auto ctocFrame = dynamic_cast(*it); CPPUNIT_ASSERT_EQUAL(ByteVector("toc"), ctocFrame->elementID()); CPPUNIT_ASSERT(!ctocFrame->isTopLevel()); CPPUNIT_ASSERT(!ctocFrame->isOrdered()); CPPUNIT_ASSERT_EQUAL(129U, ctocFrame->entryCount()); const ID3v2::FrameList &embeddedFrames = ctocFrame->embeddedFrameList(); CPPUNIT_ASSERT_EQUAL(1U, embeddedFrames.size()); - const ID3v2::TextIdentificationFrame *tit2Frame = - dynamic_cast( + auto tit2Frame = dynamic_cast( embeddedFrames.front()); CPPUNIT_ASSERT(tit2Frame); CPPUNIT_ASSERT_EQUAL(StringList("toplevel toc"), tit2Frame->fieldList()); diff --git a/tests/test_list.cpp b/tests/test_list.cpp index 1c6d8c4c..1af9a6f7 100644 --- a/tests/test_list.cpp +++ b/tests/test_list.cpp @@ -65,7 +65,7 @@ public: l1.append(4); List l2 = l1; - List::Iterator it = l2.find(3); + auto it = l2.find(3); *it = 33; CPPUNIT_ASSERT_EQUAL(3, l1[2]); CPPUNIT_ASSERT_EQUAL(33, l2[2]); diff --git a/tests/test_map.cpp b/tests/test_map.cpp index b5e493b6..e8012a3f 100644 --- a/tests/test_map.cpp +++ b/tests/test_map.cpp @@ -61,7 +61,7 @@ public: m1.insert("carol", 11); Map m2 = m1; - Map::Iterator it = m2.find("bob"); + auto it = m2.find("bob"); (*it).second = 99; CPPUNIT_ASSERT_EQUAL(9, m1["bob"]); CPPUNIT_ASSERT_EQUAL(99, m2["bob"]); diff --git a/tests/test_xiphcomment.cpp b/tests/test_xiphcomment.cpp index 386a3e67..311a8862 100644 --- a/tests/test_xiphcomment.cpp +++ b/tests/test_xiphcomment.cpp @@ -167,7 +167,7 @@ public: { Vorbis::File f(newname.c_str()); - FLAC::Picture *newpic = new FLAC::Picture(); + auto newpic = new FLAC::Picture(); newpic->setType(FLAC::Picture::BackCover); newpic->setWidth(5); newpic->setHeight(6);