mirror of
https://github.com/taglib/taglib.git
synced 2025-05-27 21:20:26 -04:00
clang-tidy: replace static_cast with dynamic_cast (#1021)
* clang-tidy: replace static_cast with dynamic_cast Found with cppcoreguidelines-pro-type-static-cast-downcast Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
parent
07eb81e88a
commit
f581615110
@ -340,19 +340,20 @@ void FrameFactory::rebuildAggregateFrames(ID3v2::Tag *tag) const
|
||||
{
|
||||
TextIdentificationFrame *tdrc =
|
||||
dynamic_cast<TextIdentificationFrame *>(tag->frameList("TDRC").front());
|
||||
UnknownFrame *tdat = static_cast<UnknownFrame *>(tag->frameList("TDAT").front());
|
||||
UnknownFrame *tdat = dynamic_cast<UnknownFrame *>(tag->frameList("TDAT").front());
|
||||
|
||||
if(tdrc &&
|
||||
tdrc->fieldList().size() == 1 &&
|
||||
tdrc->fieldList().front().size() == 4 &&
|
||||
tdat &&
|
||||
tdat->data().size() >= 5)
|
||||
{
|
||||
String date(tdat->data().mid(1), String::Type(tdat->data()[0]));
|
||||
if(date.length() == 4) {
|
||||
tdrc->setText(tdrc->toString() + '-' + date.substr(2, 2) + '-' + date.substr(0, 2));
|
||||
if(tag->frameList("TIME").size() == 1) {
|
||||
UnknownFrame *timeframe = static_cast<UnknownFrame *>(tag->frameList("TIME").front());
|
||||
if(timeframe->data().size() >= 5) {
|
||||
UnknownFrame *timeframe = dynamic_cast<UnknownFrame *>(tag->frameList("TIME").front());
|
||||
if(timeframe && timeframe->data().size() >= 5) {
|
||||
String time(timeframe->data().mid(1), String::Type(timeframe->data()[0]));
|
||||
if(time.length() == 4) {
|
||||
tdrc->setText(tdrc->toString() + 'T' + time.substr(0, 2) + ':' + time.substr(2, 2));
|
||||
|
@ -185,8 +185,10 @@ String ID3v2::Tag::genre() const
|
||||
// should be separated by " / " instead of " ". For the moment to keep
|
||||
// the behavior the same as released versions it is being left with " ".
|
||||
|
||||
if(d->frameListMap["TCON"].isEmpty() ||
|
||||
!dynamic_cast<TextIdentificationFrame *>(d->frameListMap["TCON"].front()))
|
||||
const FrameList &tconFrames = d->frameListMap["TCON"];
|
||||
TextIdentificationFrame *f;
|
||||
if(tconFrames.isEmpty() ||
|
||||
!(f = dynamic_cast<TextIdentificationFrame *>(tconFrames.front())))
|
||||
{
|
||||
return String();
|
||||
}
|
||||
@ -197,9 +199,6 @@ String ID3v2::Tag::genre() const
|
||||
// appended to the genre string. Multiple fields will be appended as the
|
||||
// string is built.
|
||||
|
||||
TextIdentificationFrame *f = static_cast<TextIdentificationFrame *>(
|
||||
d->frameListMap["TCON"].front());
|
||||
|
||||
StringList fields = f->fieldList();
|
||||
|
||||
StringList genres;
|
||||
|
Loading…
Reference in New Issue
Block a user