*/
virtual bool isEmpty() const;
+ /*!
+ * \deprecated
+ */
+ AttributeListMap &attributeListMap();
+
/*!
* Returns a reference to the item list map. This is an AttributeListMap of
* all of the items in the tag.
- *
- * This is the most powerfull structure for accessing the items of the tag.
*/
- AttributeListMap &attributeListMap();
+ const AttributeListMap &attributeListMap() const;
+
+ /*!
+ * \return True if a value for \a attribute is currently set.
+ */
+ bool contains(const String &name) const;
/*!
* Removes the \a key attribute from the tag
*/
void removeItem(const String &name);
+ /*!
+ * \return The list of values for the key \a name, or an empty list if no
+ * values have been set.
+ */
+ AttributeList attribute(const String &name) const;
+
/*!
* Sets the \a key attribute to the value of \a attribute. If an attribute
* with the \a key is already present, it will be replaced.
*/
void setAttribute(const String &name, const Attribute &attribute);
+ /*!
+ * Sets multiple \a values to the key \a name.
+ */
+ void setAttribute(const String &name, const AttributeList &values);
+
/*!
* Sets the \a key attribute to the value of \a attribute. If an attribute
* with the \a key is already present, it will be added to the list.
ASF::AttributeList values;
values.append("Foo");
values.append("Bar");
- f->tag()->attributeListMap()["WM/AlbumTitle"] = values;
+ f->tag()->setAttribute("WM/AlbumTitle", values);
f->save();
delete f;
string newname = copy.fileName();
ASF::File *f = new ASF::File(newname.c_str());
- CPPUNIT_ASSERT(!f->tag()->attributeListMap().contains("WM/TrackNumber"));
+ CPPUNIT_ASSERT(!f->tag()->contains("WM/TrackNumber"));
f->tag()->setAttribute("WM/TrackNumber", (unsigned int)(123));
f->save();
delete f;
f = new ASF::File(newname.c_str());
- CPPUNIT_ASSERT(f->tag()->attributeListMap().contains("WM/TrackNumber"));
- CPPUNIT_ASSERT_EQUAL(ASF::Attribute::DWordType, f->tag()->attributeListMap()["WM/TrackNumber"].front().type());
+ CPPUNIT_ASSERT(f->tag()->contains("WM/TrackNumber"));
+ CPPUNIT_ASSERT_EQUAL(ASF::Attribute::DWordType,
+ f->tag()->attribute("WM/TrackNumber").front().type());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(123), f->tag()->track());
f->tag()->setTrack(234);
f->save();
delete f;
f = new ASF::File(newname.c_str());
- CPPUNIT_ASSERT(f->tag()->attributeListMap().contains("WM/TrackNumber"));
- CPPUNIT_ASSERT_EQUAL(ASF::Attribute::UnicodeType, f->tag()->attributeListMap()["WM/TrackNumber"].front().type());
+ CPPUNIT_ASSERT(f->tag()->contains("WM/TrackNumber"));
+ CPPUNIT_ASSERT_EQUAL(ASF::Attribute::UnicodeType,
+ f->tag()->attribute("WM/TrackNumber").front().type());
CPPUNIT_ASSERT_EQUAL(TagLib::uint(234), f->tag()->track());
delete f;
}
string newname = copy.fileName();
ASF::File *f = new ASF::File(newname.c_str());
- ASF::AttributeList values;
ASF::Attribute attr("Foo");
attr.setStream(43);
- values.append(attr);
- f->tag()->attributeListMap()["WM/AlbumTitle"] = values;
+ f->tag()->setAttribute("WM/AlbumTitle", attr);
f->save();
delete f;
f = new ASF::File(newname.c_str());
- CPPUNIT_ASSERT_EQUAL(43, f->tag()->attributeListMap()["WM/AlbumTitle"][0].stream());
+ CPPUNIT_ASSERT_EQUAL(43, f->tag()->attribute("WM/AlbumTitle").front().stream());
delete f;
}
string newname = copy.fileName();
ASF::File *f = new ASF::File(newname.c_str());
- ASF::AttributeList values;
ASF::Attribute attr("Foo");
attr.setStream(32);
attr.setLanguage(56);
- values.append(attr);
- f->tag()->attributeListMap()["WM/AlbumTitle"] = values;
+ f->tag()->setAttribute("WM/AlbumTitle", attr);
f->save();
delete f;
f = new ASF::File(newname.c_str());
- CPPUNIT_ASSERT_EQUAL(32, f->tag()->attributeListMap()["WM/AlbumTitle"][0].stream());
- CPPUNIT_ASSERT_EQUAL(56, f->tag()->attributeListMap()["WM/AlbumTitle"][0].language());
+ CPPUNIT_ASSERT_EQUAL(32, f->tag()->attribute("WM/AlbumTitle").front().stream());
+ CPPUNIT_ASSERT_EQUAL(56, f->tag()->attribute("WM/AlbumTitle").front().language());
delete f;
}
string newname = copy.fileName();
ASF::File *f = new ASF::File(newname.c_str());
- ASF::AttributeList values;
ASF::Attribute attr(ByteVector(70000, 'x'));
- values.append(attr);
- f->tag()->attributeListMap()["WM/Blob"] = values;
+ f->tag()->setAttribute("WM/Blob", attr);
f->save();
delete f;
f = new ASF::File(newname.c_str());
- CPPUNIT_ASSERT_EQUAL(ByteVector(70000, 'x'), f->tag()->attributeListMap()["WM/Blob"][0].toByteVector());
+ CPPUNIT_ASSERT_EQUAL(ByteVector(70000, 'x'),
+ f->tag()->attribute("WM/Blob").front().toByteVector());
delete f;
}
string newname = copy.fileName();
ASF::File *f = new ASF::File(newname.c_str());
- ASF::AttributeList values;
ASF::Picture picture;
picture.setMimeType("image/jpeg");
picture.setType(ASF::Picture::FrontCover);
picture.setDescription("description");
picture.setPicture("data");
- ASF::Attribute attr(picture);
- values.append(attr);
- f->tag()->attributeListMap()["WM/Picture"] = values;
+ f->tag()->setAttribute("WM/Picture", picture);
f->save();
delete f;
f = new ASF::File(newname.c_str());
- ASF::AttributeList values2 = f->tag()->attributeListMap()["WM/Picture"];
+ ASF::AttributeList values2 = f->tag()->attribute("WM/Picture");
CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), values2.size());
ASF::Attribute attr2 = values2.front();
ASF::Picture picture2 = attr2.toPicture();
picture2.setDescription("back cover");
picture2.setPicture("PNG data");
values.append(ASF::Attribute(picture2));
- f->tag()->attributeListMap()["WM/Picture"] = values;
+ f->tag()->setAttribute("WM/Picture", values);
f->save();
delete f;
f = new ASF::File(newname.c_str());
- ASF::AttributeList values2 = f->tag()->attributeListMap()["WM/Picture"];
+ ASF::AttributeList values2 = f->tag()->attribute("WM/Picture");
CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), values2.size());
ASF::Picture picture3 = values2[1].toPicture();
CPPUNIT_ASSERT(picture3.isValid());
void testProperties()
{
ASF::File f(TEST_FILE_PATH_C("silence-1.wma"));
-
+
PropertyMap tags = f.properties();
tags["TRACKNUMBER"] = StringList("2");
CPPUNIT_ASSERT_EQUAL(String("Foo Bar"), f.tag()->artist());
CPPUNIT_ASSERT_EQUAL(StringList("Foo Bar"), tags["ARTIST"]);
- CPPUNIT_ASSERT(f.tag()->attributeListMap().contains("WM/BeatsPerMinute"));
+ CPPUNIT_ASSERT(f.tag()->contains("WM/BeatsPerMinute"));
CPPUNIT_ASSERT_EQUAL(1u, f.tag()->attributeListMap()["WM/BeatsPerMinute"].size());
- CPPUNIT_ASSERT_EQUAL(String("123"), f.tag()->attributeListMap()["WM/BeatsPerMinute"].front().toString());
+ CPPUNIT_ASSERT_EQUAL(String("123"), f.tag()->attribute("WM/BeatsPerMinute").front().toString());
CPPUNIT_ASSERT_EQUAL(StringList("123"), tags["BPM"]);
- CPPUNIT_ASSERT(f.tag()->attributeListMap().contains("WM/TrackNumber"));
+ CPPUNIT_ASSERT(f.tag()->contains("WM/TrackNumber"));
CPPUNIT_ASSERT_EQUAL(1u, f.tag()->attributeListMap()["WM/TrackNumber"].size());
- CPPUNIT_ASSERT_EQUAL(String("2"), f.tag()->attributeListMap()["WM/TrackNumber"].front().toString());
+ CPPUNIT_ASSERT_EQUAL(String("2"), f.tag()->attribute("WM/TrackNumber").front().toString());
CPPUNIT_ASSERT_EQUAL(StringList("2"), tags["TRACKNUMBER"]);
- CPPUNIT_ASSERT(f.tag()->attributeListMap().contains("WM/PartOfSet"));
+ CPPUNIT_ASSERT(f.tag()->contains("WM/PartOfSet"));
CPPUNIT_ASSERT_EQUAL(1u, f.tag()->attributeListMap()["WM/PartOfSet"].size());
- CPPUNIT_ASSERT_EQUAL(String("3"), f.tag()->attributeListMap()["WM/PartOfSet"].front().toString());
+ CPPUNIT_ASSERT_EQUAL(String("3"), f.tag()->attribute("WM/PartOfSet").front().toString());
CPPUNIT_ASSERT_EQUAL(StringList("3"), tags["DISCNUMBER"]);
}