Exemplo n.º 1
0
  void testDictInterface2()
  {
    ScopedFileCopy copy("test", ".ogg");
    string newname = copy.fileName();

    Vorbis::File *f = new Vorbis::File(newname.c_str());
    PropertyMap tags = f->tag()->properties();

    CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), tags["UNUSUALTAG"].size());
    CPPUNIT_ASSERT_EQUAL(String("usual value"), tags["UNUSUALTAG"][0]);
    CPPUNIT_ASSERT_EQUAL(String("another value"), tags["UNUSUALTAG"][1]);
    CPPUNIT_ASSERT_EQUAL(
      String("\xC3\xB6\xC3\xA4\xC3\xBC\x6F\xCE\xA3\xC3\xB8", String::UTF8),
      tags["UNICODETAG"][0]);

    tags["UNICODETAG"][0] = String(
      "\xCE\xBD\xCE\xB5\xCF\x89\x20\xCE\xBD\xCE\xB1\xCE\xBB\xCF\x85\xCE\xB5", String::UTF8);
    tags.erase("UNUSUALTAG");
    f->tag()->setProperties(tags);
    CPPUNIT_ASSERT_EQUAL(
      String("\xCE\xBD\xCE\xB5\xCF\x89\x20\xCE\xBD\xCE\xB1\xCE\xBB\xCF\x85\xCE\xB5", String::UTF8),
      f->tag()->properties()["UNICODETAG"][0]);
    CPPUNIT_ASSERT_EQUAL(false, f->tag()->properties().contains("UNUSUALTAG"));

    delete f;
  }
Exemplo n.º 2
0
PropertyMap ID3v2::Tag::setProperties(const PropertyMap &origProps)
{
  FrameList framesToDelete;
  // we split up the PropertyMap into the "normal" keys and the "complicated" ones,
  // which are those according to TIPL or TMCL frames.
  PropertyMap properties;
  PropertyMap tiplProperties;
  PropertyMap tmclProperties;
  Frame::splitProperties(origProps, properties, tiplProperties, tmclProperties);
  for(FrameListMap::ConstIterator it = frameListMap().begin(); it != frameListMap().end(); ++it){
    for(FrameList::ConstIterator lit = it->second.begin(); lit != it->second.end(); ++lit){
      PropertyMap frameProperties = (*lit)->asProperties();
      if(it->first == "TIPL") {
        if (tiplProperties != frameProperties)
          framesToDelete.append(*lit);
        else
          tiplProperties.erase(frameProperties);
      } else if(it->first == "TMCL") {
        if (tmclProperties != frameProperties)
          framesToDelete.append(*lit);
        else
          tmclProperties.erase(frameProperties);
      } else if(!properties.contains(frameProperties))
        framesToDelete.append(*lit);
      else
        properties.erase(frameProperties);
    }
  }
  for(FrameList::ConstIterator it = framesToDelete.begin(); it != framesToDelete.end(); ++it)
    removeFrame(*it);

  // now create remaining frames:
  // start with the involved people list (TIPL)
  if(!tiplProperties.isEmpty())
      addFrame(TextIdentificationFrame::createTIPLFrame(tiplProperties));
  // proceed with the musician credit list (TMCL)
  if(!tmclProperties.isEmpty())
      addFrame(TextIdentificationFrame::createTMCLFrame(tmclProperties));
  // now create the "one key per frame" frames
  for(PropertyMap::ConstIterator it = properties.begin(); it != properties.end(); ++it)
    addFrame(Frame::createTextualFrame(it->first, it->second));
  return PropertyMap(); // ID3 implements the complete PropertyMap interface, so an empty map is returned
}
Exemplo n.º 3
0
  void testInsertAndExtract()
  {
    ScopedFileCopy copy("matroska", ".mka");
    string filename = copy.fileName();

    {
      EBML::Matroska::File f1(filename.c_str());
      CPPUNIT_ASSERT(f1.isValid());

      Tag* t = f1.tag();

      CPPUNIT_ASSERT(t != 0);
      t->setTitle("Seconds of Silence");
      t->setArtist("Nobody");
      t->setAlbum("TagLib Test Suite");
      t->setComment("Well, there's nothing to say - a few special signs: ©’…ä–€ſ");
      t->setGenre("Air");
      t->setYear(2013);
      t->setTrack(15);

      CPPUNIT_ASSERT(f1.save());
    }
    {
      EBML::Matroska::File f2(filename.c_str());
      CPPUNIT_ASSERT(f2.isValid());

      Tag* t = f2.tag();

      CPPUNIT_ASSERT(t != 0);
      CPPUNIT_ASSERT_EQUAL(String("Seconds of Silence"), t->title());
      CPPUNIT_ASSERT_EQUAL(String("Nobody"), t->artist());
      CPPUNIT_ASSERT_EQUAL(String("TagLib Test Suite"), t->album());
      CPPUNIT_ASSERT_EQUAL(String("Well, there's nothing to say - a few special signs: ©’…ä–€ſ"), t->comment());
      CPPUNIT_ASSERT_EQUAL(String("Air"), t->genre());
      CPPUNIT_ASSERT_EQUAL(2013u, t->year());
      CPPUNIT_ASSERT_EQUAL(15u, t->track());

      PropertyMap pm = f2.properties();
      pm.erase("COMMENT");
      f2.setProperties(pm);

      CPPUNIT_ASSERT(f2.save());
    }

    {
      EBML::Matroska::File f3(filename.c_str());
      CPPUNIT_ASSERT(f3.isValid());

      PropertyMap pm = f3.properties();
      PropertyMap::Iterator i = pm.find("GENRE");

      CPPUNIT_ASSERT(i != pm.end());
      CPPUNIT_ASSERT_EQUAL(String("Air"), i->second.front());
    }
  }
Exemplo n.º 4
0
void
Event::unset(const PropertyName &name)
{
#ifndef NDEBUG
    ++m_unsetCount;
#endif

    unshare();
    PropertyMap::iterator i;
    PropertyMap *map = find(name, i);
    if (map) {
	delete i->second;
	map->erase(i);
    }
}