From 23b418b4e9609c270a4f6c26c39e66d61ef61820 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Tue, 17 Sep 2013 14:59:19 +0900 Subject: [PATCH] Added a missing fieldListmap() method to RIFF::Info::Tag --- taglib/riff/wav/infotag.cpp | 5 +++++ taglib/riff/wav/infotag.h | 12 ++++++++++++ tests/CMakeLists.txt | 1 + tests/test_info.cpp | 10 +++++++--- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/taglib/riff/wav/infotag.cpp b/taglib/riff/wav/infotag.cpp index 658ede88..09edfa53 100644 --- a/taglib/riff/wav/infotag.cpp +++ b/taglib/riff/wav/infotag.cpp @@ -185,6 +185,11 @@ bool RIFF::Info::Tag::isEmpty() const return d->fieldListMap.isEmpty(); } +FieldListMap RIFF::Info::Tag::fieldListMap() const +{ + return d->fieldListMap; +} + String RIFF::Info::Tag::fieldText(const ByteVector &id) const { if(d->fieldListMap.contains(id)) diff --git a/taglib/riff/wav/infotag.h b/taglib/riff/wav/infotag.h index 9a26d4cb..4007ae66 100644 --- a/taglib/riff/wav/infotag.h +++ b/taglib/riff/wav/infotag.h @@ -120,6 +120,18 @@ namespace TagLib { virtual bool isEmpty() const; + /*! + * Returns a copy of the internal fields of the tag. The returned map directly + * reflects the contents of the "INFO" chunk. + * + * \note Modifying this map does not affect the tag's internal data. + * Use setFieldText() and removeField() instead. + * + * \see setFieldText() + * \see removeField() + */ + FieldListMap fieldListMap() const; + /* * Gets the value of the field with the ID \a id. */ diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4e428af8..7a3d0bd5 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -52,6 +52,7 @@ SET(test_runner_SRCS test_ape.cpp test_apetag.cpp test_wav.cpp + test_info.cpp test_wavpack.cpp test_mp4.cpp test_mp4item.cpp diff --git a/tests/test_info.cpp b/tests/test_info.cpp index f76fd67a..8e0d7154 100644 --- a/tests/test_info.cpp +++ b/tests/test_info.cpp @@ -1,9 +1,7 @@ -#include #include #include #include -#include -#include +#include #include "utils.h" using namespace std; @@ -23,7 +21,13 @@ public: CPPUNIT_ASSERT_EQUAL(String(""), tag.title()); tag.setTitle("Test title 1"); + tag.setFieldText("TEST", "Dummy Text"); + CPPUNIT_ASSERT_EQUAL(String("Test title 1"), tag.title()); + + RIFF::Info::FieldListMap map = tag.fieldListMap(); + CPPUNIT_ASSERT_EQUAL(String("Test title 1"), map["INAM"]); + CPPUNIT_ASSERT_EQUAL(String("Dummy Text"), map["TEST"]); } void testNumericFields()