mirror of
https://github.com/taglib/taglib.git
synced 2025-05-27 21:20:26 -04:00
Merge branch 'master' into merge-master-to-taglib2
# Conflicts: # taglib/mp4/mp4atom.cpp # taglib/toolkit/tlist.tcc # taglib/toolkit/tmap.tcc # tests/test_asf.cpp # tests/test_ogg.cpp # tests/test_oggflac.cpp # tests/test_opus.cpp # tests/test_speex.cpp
This commit is contained in:
commit
13223ad497
@ -232,6 +232,11 @@ namespace TagLib {
|
||||
*/
|
||||
List<T> &operator=(const List<T> &l);
|
||||
|
||||
/*!
|
||||
* Exchanges the content of this list by the content of \a l.
|
||||
*/
|
||||
void swap(List<T> &l);
|
||||
|
||||
/*!
|
||||
* Compares this list with \a l and returns true if all of the elements are
|
||||
* the same.
|
||||
|
@ -118,8 +118,8 @@ private:
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <class T>
|
||||
List<T>::List()
|
||||
: d(new ListPrivate<T>())
|
||||
List<T>::List() :
|
||||
d(new ListPrivate<T>())
|
||||
{
|
||||
}
|
||||
|
||||
@ -316,16 +316,18 @@ const T &List<T>::operator[](size_t i) const
|
||||
template <class T>
|
||||
List<T> &List<T>::operator=(const List<T> &l)
|
||||
{
|
||||
if(&l == this)
|
||||
return *this;
|
||||
|
||||
if(d->deref())
|
||||
delete d;
|
||||
d = l.d;
|
||||
d->ref();
|
||||
List<T>(l).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void List<T>::swap(List<T> &l)
|
||||
{
|
||||
using std::swap;
|
||||
|
||||
swap(d, l.d);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool List<T>::operator==(const List<T> &l) const
|
||||
{
|
||||
|
@ -178,6 +178,11 @@ namespace TagLib {
|
||||
*/
|
||||
Map<Key, T> &operator=(const Map<Key, T> &m);
|
||||
|
||||
/*!
|
||||
* Exchanges the content of this map by the content of \a m.
|
||||
*/
|
||||
void swap(Map<Key, T> &m);
|
||||
|
||||
protected:
|
||||
/*
|
||||
* If this List is being shared via implicit sharing, do a deep copy of the
|
||||
|
@ -51,8 +51,8 @@ public:
|
||||
};
|
||||
|
||||
template <class Key, class T>
|
||||
Map<Key, T>::Map()
|
||||
: d(new MapPrivate<Key, T>())
|
||||
Map<Key, T>::Map() :
|
||||
d(new MapPrivate<Key, T>())
|
||||
{
|
||||
}
|
||||
|
||||
@ -174,16 +174,18 @@ T &Map<Key, T>::operator[](const Key &key)
|
||||
template <class Key, class T>
|
||||
Map<Key, T> &Map<Key, T>::operator=(const Map<Key, T> &m)
|
||||
{
|
||||
if(&m == this)
|
||||
return *this;
|
||||
|
||||
if(d->deref())
|
||||
delete(d);
|
||||
d = m.d;
|
||||
d->ref();
|
||||
Map<Key, T>(m).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class Key, class T>
|
||||
void Map<Key, T>::swap(Map<Key, T> &m)
|
||||
{
|
||||
using std::swap;
|
||||
|
||||
swap(d, m.d);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// protected members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -310,10 +310,10 @@ public:
|
||||
|
||||
{
|
||||
ASF::File f(copy.fileName().c_str());
|
||||
f.tag()->setTitle(std::string(128 * 1024, 'X').c_str());
|
||||
f.tag()->setTitle(longText(128 * 1024));
|
||||
f.save();
|
||||
CPPUNIT_ASSERT_EQUAL(297578LL, f.length());
|
||||
f.tag()->setTitle(std::string(16 * 1024, 'X').c_str());
|
||||
f.tag()->setTitle(longText(16 * 1024));
|
||||
f.save();
|
||||
CPPUNIT_ASSERT_EQUAL(68202LL, f.length());
|
||||
}
|
||||
|
@ -259,7 +259,7 @@ public:
|
||||
ScopedFileCopy copy("no-tags", ".flac");
|
||||
|
||||
FLAC::File f(copy.fileName().c_str());
|
||||
f.xiphComment()->setTitle(std::string(8 * 1024, 'X').c_str());
|
||||
f.xiphComment()->setTitle(longText(8 * 1024));
|
||||
f.save();
|
||||
CPPUNIT_ASSERT_EQUAL(12862LL, f.length());
|
||||
f.save();
|
||||
@ -372,7 +372,7 @@ public:
|
||||
|
||||
{
|
||||
FLAC::File f(copy.fileName().c_str());
|
||||
f.xiphComment()->setTitle(std::wstring(128 * 1024, L'X').c_str());
|
||||
f.xiphComment()->setTitle(longText(128 * 1024));
|
||||
f.save();
|
||||
CPPUNIT_ASSERT(f.length() > 128 * 1024);
|
||||
}
|
||||
|
@ -1147,7 +1147,7 @@ public:
|
||||
|
||||
{
|
||||
MPEG::File f(newname.c_str());
|
||||
f.ID3v2Tag()->setTitle(std::wstring(64 * 1024, L'X').c_str());
|
||||
f.ID3v2Tag()->setTitle(longText(64 * 1024));
|
||||
f.save(MPEG::File::ID3v2, true);
|
||||
}
|
||||
{
|
||||
|
@ -72,13 +72,11 @@ public:
|
||||
ScopedFileCopy copy("empty", ".ogg");
|
||||
string newname = copy.fileName();
|
||||
|
||||
String longText(std::string(128 * 1024, ' ').c_str());
|
||||
for (size_t i = 0; i < longText.length(); ++i)
|
||||
longText[i] = static_cast<wchar_t>(L'A' + (i % 26));
|
||||
const String text = longText(128 * 1024, true);
|
||||
|
||||
{
|
||||
Ogg::Vorbis::File f(newname.c_str());
|
||||
f.tag()->setTitle(longText);
|
||||
f.tag()->setTitle(text);
|
||||
f.save();
|
||||
}
|
||||
{
|
||||
@ -89,7 +87,7 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)30, f.packet(0).size());
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)131127, f.packet(1).size());
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)3832, f.packet(2).size());
|
||||
CPPUNIT_ASSERT_EQUAL(longText, f.tag()->title());
|
||||
CPPUNIT_ASSERT_EQUAL(text, f.tag()->title());
|
||||
|
||||
CPPUNIT_ASSERT(f.audioProperties());
|
||||
CPPUNIT_ASSERT_EQUAL(3685, f.audioProperties()->lengthInMilliseconds());
|
||||
|
@ -77,13 +77,11 @@ public:
|
||||
ScopedFileCopy copy("empty_flac", ".oga");
|
||||
string newname = copy.fileName();
|
||||
|
||||
String longText(std::string(128 * 1024, ' ').c_str());
|
||||
for(size_t i = 0; i < longText.length(); ++i)
|
||||
longText[i] = static_cast<wchar_t>(L'A' + (i % 26));
|
||||
const String text = longText(128 * 1024, true);
|
||||
|
||||
{
|
||||
Ogg::FLAC::File f(newname.c_str());
|
||||
f.tag()->setTitle(longText);
|
||||
f.tag()->setTitle(text);
|
||||
f.save();
|
||||
}
|
||||
{
|
||||
@ -95,7 +93,7 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)131126, f.packet(1).size());
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)22, f.packet(2).size());
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)8196, f.packet(3).size());
|
||||
CPPUNIT_ASSERT_EQUAL(longText, f.tag()->title());
|
||||
CPPUNIT_ASSERT_EQUAL(text, f.tag()->title());
|
||||
|
||||
CPPUNIT_ASSERT(f.audioProperties());
|
||||
CPPUNIT_ASSERT_EQUAL(3705, f.audioProperties()->lengthInMilliseconds());
|
||||
|
@ -93,13 +93,11 @@ public:
|
||||
ScopedFileCopy copy("correctness_gain_silent_output", ".opus");
|
||||
string newname = copy.fileName();
|
||||
|
||||
String longText(std::string(128 * 1024, ' ').c_str());
|
||||
for(size_t i = 0; i < longText.length(); ++i)
|
||||
longText[i] = static_cast<wchar_t>(L'A' + (i % 26));
|
||||
const String text = longText(128 * 1024, true);
|
||||
|
||||
{
|
||||
Ogg::Opus::File f(newname.c_str());
|
||||
f.tag()->setTitle(longText);
|
||||
f.tag()->setTitle(text);
|
||||
f.save();
|
||||
}
|
||||
{
|
||||
@ -111,7 +109,7 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)131380, f.packet(1).size());
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)5, f.packet(2).size());
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)5, f.packet(3).size());
|
||||
CPPUNIT_ASSERT_EQUAL(longText, f.tag()->title());
|
||||
CPPUNIT_ASSERT_EQUAL(text, f.tag()->title());
|
||||
|
||||
CPPUNIT_ASSERT(f.audioProperties());
|
||||
CPPUNIT_ASSERT_EQUAL(7737, f.audioProperties()->lengthInMilliseconds());
|
||||
|
@ -58,13 +58,11 @@ public:
|
||||
ScopedFileCopy copy("empty", ".spx");
|
||||
string newname = copy.fileName();
|
||||
|
||||
String longText(std::string(128 * 1024, ' ').c_str());
|
||||
for (size_t i = 0; i < longText.length(); ++i)
|
||||
longText[i] = static_cast<wchar_t>(L'A' + (i % 26));
|
||||
const String text = longText(128 * 1024, true);
|
||||
|
||||
{
|
||||
Ogg::Speex::File f(newname.c_str());
|
||||
f.tag()->setTitle(longText);
|
||||
f.tag()->setTitle(text);
|
||||
f.save();
|
||||
}
|
||||
{
|
||||
@ -76,7 +74,7 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)131116, f.packet(1).size());
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)93, f.packet(2).size());
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)93, f.packet(3).size());
|
||||
CPPUNIT_ASSERT_EQUAL(longText, f.tag()->title());
|
||||
CPPUNIT_ASSERT_EQUAL(text, f.tag()->title());
|
||||
|
||||
CPPUNIT_ASSERT(f.audioProperties());
|
||||
CPPUNIT_ASSERT_EQUAL(3685, f.audioProperties()->lengthInMilliseconds());
|
||||
|
@ -103,13 +103,34 @@ inline bool fileEqual(const string &filename1, const string &filename2)
|
||||
return stream1.good() == stream2.good();
|
||||
}
|
||||
|
||||
#ifdef TAGLIB_STRING_H
|
||||
|
||||
namespace TagLib {
|
||||
|
||||
inline String longText(size_t length, bool random = false)
|
||||
{
|
||||
const wchar_t chars[] = L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_";
|
||||
|
||||
std::wstring text(length, L'X');
|
||||
|
||||
if(random) {
|
||||
for(size_t i = 0; i < length; ++i)
|
||||
text[i] = chars[rand() % 53];
|
||||
}
|
||||
|
||||
return String(text);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
class ScopedFileCopy
|
||||
{
|
||||
public:
|
||||
ScopedFileCopy(const string &filename, const string &ext, bool deleteFile=true)
|
||||
ScopedFileCopy(const string &filename, const string &ext, bool deleteFile=true) :
|
||||
m_deleteFile(deleteFile),
|
||||
m_filename(copyFile(filename, ext))
|
||||
{
|
||||
m_deleteFile = deleteFile;
|
||||
m_filename = copyFile(filename, ext);
|
||||
}
|
||||
|
||||
~ScopedFileCopy()
|
||||
@ -118,12 +139,12 @@ public:
|
||||
deleteFile(m_filename);
|
||||
}
|
||||
|
||||
string fileName()
|
||||
string fileName() const
|
||||
{
|
||||
return m_filename;
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_deleteFile;
|
||||
string m_filename;
|
||||
const bool m_deleteFile;
|
||||
const string m_filename;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user