]> granicus.if.org Git - taglib/commitdiff
Add isEmpty() to MP4
authorScott Wheeler <scott@directededge.com>
Mon, 18 May 2015 18:30:19 +0000 (20:30 +0200)
committerScott Wheeler <scott@directededge.com>
Mon, 18 May 2015 18:30:19 +0000 (20:30 +0200)
Closes #457

taglib/mp4/mp4tag.cpp
taglib/mp4/mp4tag.h
tests/test_mp4.cpp

index 1a2fec7c6d9f029484d1b79d967df3755ead9a63..08e5f411a9cea1c36d3f20a7b556195507b9dda5 100644 (file)
@@ -760,6 +760,11 @@ MP4::Tag::setTrack(uint value)
   d->items["trkn"] = MP4::Item(value, 0);
 }
 
+bool MP4::Tag::isEmpty() const
+{
+  return d->items.isEmpty();
+}
+
 MP4::ItemListMap &
 MP4::Tag::itemListMap()
 {
index 48d71fcb9f940d4f2a7b717757b862b6f9bf37cc..cde68964e36676dd38e5f6f36c022264fa7a4d79 100644 (file)
@@ -65,6 +65,8 @@ namespace TagLib {
         void setYear(uint value);
         void setTrack(uint value);
 
+        virtual bool isEmpty() const;
+
         ItemListMap &itemListMap();
 
         PropertyMap properties() const;
index ac4d4907ac5750fc805f61903ac304623cbf2580..9bd2deb7ab176be8438e4f6d3a66140c73b3acfa 100644 (file)
@@ -19,6 +19,7 @@ class TestMP4 : public CppUnit::TestFixture
   CPPUNIT_TEST(testPropertiesALAC);
   CPPUNIT_TEST(testFreeForm);
   CPPUNIT_TEST(testCheckValid);
+  CPPUNIT_TEST(testIsEmpty);
   CPPUNIT_TEST(testUpdateStco);
   CPPUNIT_TEST(testSaveExisingWhenIlstIsLast);
   CPPUNIT_TEST(test64BitAtom);
@@ -62,6 +63,18 @@ public:
     CPPUNIT_ASSERT(f2.isValid());
   }
 
+  void testIsEmpty()
+  {
+    MP4::Tag t1;
+    CPPUNIT_ASSERT(t1.isEmpty());
+    t1.setArtist("Foo");
+    CPPUNIT_ASSERT(!t1.isEmpty());
+
+    MP4::Tag t2;
+    t2.itemListMap()["foo"] = "bar";
+    CPPUNIT_ASSERT(!t2.isEmpty());
+  }
+
   void testUpdateStco()
   {
     ScopedFileCopy copy("no-tags", ".3g2");