]> diplodocus.org Git - flac-archive/commitdiff
looks like i got rid of ByteVectorSet on Mar 11 15:18 but didn't commit
authorepg@pretzelnet.org <>
Mon, 7 Apr 2014 05:39:30 +0000 (22:39 -0700)
committerepg@pretzelnet.org <>
Mon, 7 Apr 2014 05:39:30 +0000 (22:39 -0700)
strip-tags.cc

index 2f18cd0..fed0624 100644 (file)
@@ -13,21 +13,18 @@ extern "C" {
 
 using std::cerr;
 using std::endl;
-using std::shared_ptr;
 using std::vector;
 
-typedef vector<shared_ptr<TagLib::ByteVector>> ByteVectorSet;
-
 static bool diag = true;
 static bool force_write = false;
 static bool strip_v1 = true;
 
+template <class T>
 static bool
-ByteVectorSet_has(const ByteVectorSet &set,
-                  const TagLib::ByteVector &target)
+vector_has(const vector<T> &vector, const T &target)
 {
-    for (const auto vector : set) {
-        if (*vector == target) {
+    for (const auto &element : vector) {
+        if (element == target) {
             return true;
         }
     }
@@ -36,7 +33,7 @@ ByteVectorSet_has(const ByteVectorSet &set,
 
 static bool
 delete_id3v2_frames(TagLib::MPEG::File &file,
-                    const ByteVectorSet &delete_frame_ids)
+                    const vector<TagLib::ByteVector> &delete_frame_ids)
 {
     TagLib::ID3v2::Tag *tag = file.ID3v2Tag();
     // Build a list of frames to delete in delete_frames.
@@ -46,7 +43,7 @@ delete_id3v2_frames(TagLib::MPEG::File &file,
         if (diag) {
             cerr << frameid;
         }
-        if (ByteVectorSet_has(delete_frame_ids, frameid)) {
+        if (vector_has(delete_frame_ids, frameid)) {
             cerr << " deleted" << endl;
             delete_frames.push_back(frame);
             continue;
@@ -68,7 +65,7 @@ delete_id3v2_frames(TagLib::MPEG::File &file,
 
 static void
 strip_tags(TagLib::MPEG::File &file,
-           const ByteVectorSet &delete_frames,
+           const vector<TagLib::ByteVector> &delete_frames,
            char *fn)
 {
     bool changed = false;
@@ -90,14 +87,13 @@ strip_tags(TagLib::MPEG::File &file,
 int
 main(int argc, char **argv)
 {
-    ByteVectorSet delete_frames;
+    vector<TagLib::ByteVector> delete_frames;
 
     int c;
     while ((c = getopt(argc, argv, "d:")) != -1) {
         switch (c) {
         case 'd': {
-            shared_ptr<TagLib::ByteVector> bv(new TagLib::ByteVector(optarg));
-            delete_frames.push_back(bv);
+            delete_frames.emplace_back(optarg);
         } break;
         default:
             // getopt printed an error.