-
Notifications
You must be signed in to change notification settings - Fork 7
/
setid3.h
78 lines (55 loc) · 2.03 KB
/
setid3.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
tag::write::ID3 applicative class
copyright (c) 2004, 2005 squell <[email protected]>
use, modification, copying and distribution of this software is permitted
under the conditions described in the file 'COPYING'.
Usage:
The write::ID3 class implements the interface for ID3 tags
Example:
int main(int argc, char* argv[])
{
tag::write::ID3()
.set(artist, "%2")
.set(title, "%3")
.modify(argv[1], argv);
}
*/
#ifndef __ZF_SETID3
#define __ZF_SETID3
#include <string>
#include <utility>
#include "set_base.h"
struct ID3v1; // avoid a header dependency
namespace tag {
namespace write {
class ID3 : public handler, public reader {
public:
bool vmodify(const char*, const function&) const;
metadata* read(const char*) const;
// standard set
ID3() : update(), cleared(), generate(), null_tag() { }
~ID3();
ID3& set(ID3field i, std::string m)
{ if(i < FIELD_MAX) update[i] = m; return *this; }
ID3& rewrite(bool t = true)
{ cleared = t; return *this; }
ID3& create(bool t = true)
{ generate = t; return *this; }
// extended
bool from(const char* fn);
private:
struct nullable : private std::pair<std::string, bool> {
struct null;
void operator=(const null*) { first.erase(), second = 0; }
void operator=(std::string p) { first.swap(p), second = 1; }
operator const std::string*() const { return second? &first : 0; }
const std::string* operator->() const { return *this; }
};
nullable update[FIELD_MAX]; // modification data
bool cleared; // should vmodify clear existing tag?
bool generate; // don't *add* new tags to files?
const ID3v1* null_tag; // use as base tag
};
}
}
#endif