Avoid using String::null where an empty string is required.

String::null is not necessarily be empty or remains the same instance.
Using it in a public header may lead to a linkage error.
This commit is contained in:
Tsuda Kageyu
2015-11-20 22:21:47 +09:00
parent c4fe65787c
commit 8c6fe45453
29 changed files with 106 additions and 105 deletions

View File

@ -184,7 +184,7 @@ void ID3v1::Tag::setGenre(const String &s)
void ID3v1::Tag::setYear(TagLib::uint i)
{
d->year = i > 0 ? String::number(i) : String::null;
d->year = i > 0 ? String::number(i) : String();
}
void ID3v1::Tag::setTrack(TagLib::uint i)

View File

@ -214,7 +214,7 @@ void TableOfContentsFrame::removeEmbeddedFrames(const ByteVector &id)
String TableOfContentsFrame::toString() const
{
return String::null;
return String();
}
PropertyMap TableOfContentsFrame::asProperties() const

View File

@ -312,8 +312,8 @@ UserTextIdentificationFrame::UserTextIdentificationFrame(String::Type encoding)
d(0)
{
StringList l;
l.append(String::null);
l.append(String::null);
l.append(String());
l.append(String());
setText(l);
}
@ -341,7 +341,7 @@ String UserTextIdentificationFrame::description() const
{
return !TextIdentificationFrame::fieldList().isEmpty()
? TextIdentificationFrame::fieldList().front()
: String::null;
: String();
}
StringList UserTextIdentificationFrame::fieldList() const
@ -354,7 +354,7 @@ StringList UserTextIdentificationFrame::fieldList() const
void UserTextIdentificationFrame::setText(const String &text)
{
if(description().isEmpty())
setDescription(String::null);
setDescription(String());
TextIdentificationFrame::setText(StringList(description()).append(text));
}
@ -362,7 +362,7 @@ void UserTextIdentificationFrame::setText(const String &text)
void UserTextIdentificationFrame::setText(const StringList &fields)
{
if(description().isEmpty())
setDescription(String::null);
setDescription(String());
TextIdentificationFrame::setText(StringList(description()).append(fields));
}
@ -417,7 +417,7 @@ void UserTextIdentificationFrame::checkFields()
int fields = fieldList().size();
if(fields == 0)
setDescription(String::null);
setDescription(String());
if(fields <= 1)
setText(String::null);
setText(String());
}

View File

@ -86,7 +86,7 @@ void UniqueFileIdentifierFrame::setIdentifier(const ByteVector &v)
String UniqueFileIdentifierFrame::toString() const
{
return String::null;
return String();
}
PropertyMap UniqueFileIdentifierFrame::asProperties() const

View File

@ -51,7 +51,7 @@ UnknownFrame::~UnknownFrame()
String UnknownFrame::toString() const
{
return String::null;
return String();
}
ByteVector UnknownFrame::data() const

View File

@ -317,7 +317,7 @@ String Frame::readStringField(const ByteVector &data, String::Type encoding, int
int end = data.find(delimiter, *position, delimiter.size());
if(end < *position)
return String::null;
return String();
String str;
if(encoding == String::Latin1)

View File

@ -516,7 +516,7 @@ void FrameFactory::updateGenre(TextIdentificationFrame *frame) const
}
if(newfields.isEmpty())
fields.append(String::null);
fields.append(String());
frame->setText(newfields);

View File

@ -140,21 +140,21 @@ String ID3v2::Tag::title() const
{
if(!d->frameListMap["TIT2"].isEmpty())
return d->frameListMap["TIT2"].front()->toString();
return String::null;
return String();
}
String ID3v2::Tag::artist() const
{
if(!d->frameListMap["TPE1"].isEmpty())
return d->frameListMap["TPE1"].front()->toString();
return String::null;
return String();
}
String ID3v2::Tag::album() const
{
if(!d->frameListMap["TALB"].isEmpty())
return d->frameListMap["TALB"].front()->toString();
return String::null;
return String();
}
String ID3v2::Tag::comment() const
@ -162,7 +162,7 @@ String ID3v2::Tag::comment() const
const FrameList &comments = d->frameListMap["COMM"];
if(comments.isEmpty())
return String::null;
return String();
for(FrameList::ConstIterator it = comments.begin(); it != comments.end(); ++it)
{
@ -184,7 +184,7 @@ String ID3v2::Tag::genre() const
if(d->frameListMap["TCON"].isEmpty() ||
!dynamic_cast<TextIdentificationFrame *>(d->frameListMap["TCON"].front()))
{
return String::null;
return String();
}
// ID3v2.4 lists genres as the fields in its frames field list. If the field