aboutsummaryrefslogtreecommitdiff
path: root/examples/test_remove.cpp
diff options
context:
space:
mode:
authorLucas Eckels <eckels@google.com>2012-08-06 15:12:54 -0700
committerLucas Eckels <eckels@google.com>2012-08-08 09:29:05 -0700
commit8a58cac9f8db5ed55b02b3ac24156d628af923d1 (patch)
tree3960df276069aefab2103e778cc52e89253b12ef /examples/test_remove.cpp
parent2f9cfa4836e5e572c0e5688bec15515355b709a1 (diff)
downloadid3lib-8a58cac9f8db5ed55b02b3ac24156d628af923d1.tar.gz
Add id3lib 3.8.3 source.
Change-Id: Ic723712b360a1760b4c081b1f6a77939bb2969a9
Diffstat (limited to 'examples/test_remove.cpp')
-rw-r--r--examples/test_remove.cpp118
1 files changed, 118 insertions, 0 deletions
diff --git a/examples/test_remove.cpp b/examples/test_remove.cpp
new file mode 100644
index 0000000..6bdfc63
--- /dev/null
+++ b/examples/test_remove.cpp
@@ -0,0 +1,118 @@
+// $Id: test_remove.cpp,v 1.13 2003/03/02 15:17:21 t1mpy Exp $
+
+#if defined(HAVE_CONFIG_H)
+# include "config.h"
+#endif
+
+#include "id3/id3lib_streams.h"
+#include "id3/tag.h"
+#include "id3/misc_support.h"
+#include "id3/id3lib_strings.h"
+
+using std::cout;
+using std::endl;
+using std::cerr;
+
+using namespace dami;
+
+typedef const char* LPCTSTR;
+
+/* CSharedTag is a wrapper I made for some features I need */
+/* LPCTSTR means const char * */
+size_t RemoveFrame(ID3_Tag& pTag, ID3_FrameID fID, LPCTSTR sDescription)
+{
+ size_t nCount = 0;
+ const ID3_Frame * frame = NULL;
+
+ do {
+ if (!sDescription)
+ {
+ cerr << "*** description is null" << endl;
+ frame = pTag.Find(fID);
+ }
+ else
+ {
+ cerr << "*** description is \"" << sDescription << "\"" << endl;
+ frame = pTag.Find(fID, ID3FN_DESCRIPTION, sDescription);
+ }
+
+ if (frame)
+ {
+ ID3_Field* fld = frame->GetField(ID3FN_TEXT);
+ String text(fld->GetRawText(), fld->Size());
+ cerr << "*** delete frame with text \"" << text << "\"" << endl;
+ /* pTag is an ID3_Tag */
+ delete pTag.RemoveFrame(frame);
+ nCount++;
+ }
+ } while (frame != NULL);
+
+ return nCount;
+}
+
+int main( int argc, char *argv[])
+{
+ ID3_Tag tag;
+ ID3_Frame frame;
+
+ if (argc == 2)
+ {
+ tag.Link(argv[1]);
+ cerr << "removed " << RemoveFrame(tag, ID3FID_COMMENT, "") << " descriptionless comment frames" << endl;
+ tag.Update();
+
+ }
+ else
+ {
+ tag.Link("test-remove.tag");
+ tag.Strip(ID3TT_ALL);
+ tag.Clear();
+
+ frame.SetID(ID3FID_TITLE);
+ frame.GetField(ID3FN_TEXT)->Set("Test title");
+ tag.AddFrame(frame);
+
+ frame.SetID(ID3FID_COMPOSER);
+ frame.GetField(ID3FN_TEXT)->Set("Test composer");
+ tag.AddFrame(frame);
+
+ frame.SetID(ID3FID_BAND);
+ frame.GetField(ID3FN_TEXT)->Set("Test band");
+ tag.AddFrame(frame);
+
+ frame.SetID(ID3FID_CONDUCTOR);
+ frame.GetField(ID3FN_TEXT)->Set("Test conductor");
+ tag.AddFrame(frame);
+
+ frame.SetID(ID3FID_COMMENT);
+ frame.GetField(ID3FN_LANGUAGE)->Set("eng");
+ frame.GetField(ID3FN_TEXT)->Set("Test comment");
+ frame.GetField(ID3FN_DESCRIPTION)->Set("A Description");
+ tag.AddFrame(frame);
+
+ frame.SetID(ID3FID_COMMENT);
+ frame.GetField(ID3FN_LANGUAGE)->Set("eng");
+ frame.GetField(ID3FN_TEXT)->Set("Test comment 2");
+ frame.GetField(ID3FN_DESCRIPTION)->Set("");
+ tag.AddFrame(frame);
+
+ frame.SetID(ID3FID_COMMENT);
+ frame.GetField(ID3FN_LANGUAGE)->Set("eng");
+ frame.GetField(ID3FN_TEXT)->Set("ID3v1 comment text?");
+ frame.GetField(ID3FN_DESCRIPTION)->Set(STR_V1_COMMENT_DESC);
+ tag.AddFrame(frame);
+
+ tag.SetPadding(false);
+ tag.Update(ID3TT_ID3V2);
+
+ cerr << "removed " << ID3_RemoveArtists(&tag) << " artist frames" << endl;
+ tag.Update();
+ cerr << "removed " << ID3_RemoveTitles(&tag) << " title frames" << endl;
+ tag.Update();
+ cerr << "removed " << RemoveFrame(tag, ID3FID_COMMENT, "") << " descriptionless comment frames" << endl;
+ tag.Update();
+ }
+
+ return 0;
+}
+