1 /*
2 
3   tag::write::ID3v2 applicative class
4 
5   copyright (c) 2004, 2005, 2015 squell <squell@alumina.nl>
6 
7   use, modification, copying and distribution of this software is permitted
8   under the conditions described in the file 'COPYING'.
9 
10   Usage:
11 
12   The write::ID3v2 class implements the single_tag interface for ID3 tags
13 
14   Limitation/Flaws:
15 
16   ID3v2 knows only the frame types classified by read::ID3v2.
17 
18   .vmodify() doesn't know about frames having multiple instances.
19 
20   a. - when updating a frame type which has multiple instances, the first one
21        will be replaced and the rest will be left unaltered.
22 
23   b. - ID3v2 will never add multiple instances of the same frame type.
24 
25   c. - deleting a frame using .rm() deletes *ALL* frames of a specific type.
26 
27   (a) requires an extra distinguisher function; for frames that have has_desc() true, append a
28       ":descriptor" to denote a unique frame
29   (b) is not a real problem, but it could be solved by porting to multimap
30   (c) is what users would expect, therefore intended behaviour
31 
32 */
33 
34 #ifndef __ZF_SETID3V2
35 #define __ZF_SETID3V2
36 
37 #include <string>
38 #include <map>
39 
40 #include "set_base.h"
41 
42 namespace tag {
43     namespace write {
44 
45         class ID3v2 : public handler, public reader {
46         public:
ID3v2()47             ID3v2() : null_tag(), mod(), resize(), fresh(), force()
48             { }
49            ~ID3v2();
50 
51             ID3v2& set(ID3field i, std::string m);      // set standard field
52             ID3v2& reserve(size_t);                     // set suggested size
53             ID3v2& rewrite(bool t = true)               // erase previous tag
54             { fresh = t; return *this; }
55             ID3v2& create(bool t = true)                // add new tags
56             { force = t; return *this; }
57 
58             bool      vmodify(const char*, const function&) const;
59             metadata* read(const char*) const;
60 
61           // extended set
62 
63             bool set(std::string field, std::string s); // set ID3v2 frame
64             bool rm(std::string field);                 // remove ID3v2 frame
65             bool from(const char*);                     // specify copy tag
66 
67         private:
68             const void* null_tag;
69             std::map<std::string,std::string> mod;
70             size_t resize;
71             bool fresh, force;
72         };
73 
74     }
75 }
76 
77 #endif
78 
79