-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathgetid3v2.h
76 lines (56 loc) · 2.22 KB
/
getid3v2.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
/*
tag::read::ID3v2
copyright (c) 2004, 2005 squell <info@squell.net>
use, modification, copying and distribution of this software is permitted
under the conditions described in the file 'COPYING'.
Usage:
The read::ID3v2 class implements the reader interface for ID3v2 tags
*/
#ifndef __ZF_GETID3V2
#define __ZF_GETID3V2
#include <string>
#include <cctype>
#include "set_base.h"
namespace tag {
namespace read {
class ID3v2 : public metadata {
public:
const void* const tag;
typedef metadata::factory<ID3v2> factory;
explicit ID3v2(const char* fn);
explicit ID3v2(const void* id3v2_data);
~ID3v2();
value_string operator[](ID3field field) const;
array listing() const;
operator bool() const { return tag; }
static bool has_lang(const std::string field) // implies has_enc
{ return field == "COMM" || field == "COM" ||
field == "USLT" || field == "ULT" ||
field == "USER"; }
static bool has_desc(const std::string field) // implies has_enc
{ return field == "TXXX" || field == "TXX" ||
field == "WXXX" || field == "WXX" ||
field == "COMM" || field == "COM" ||
field == "USLT" || field == "ULT" ||
field == "POPM" || field == "POP"; }
static bool is_counter(const std::string field)
{ return field == "PCNT" || field == "CNT" ||
field == "POPM" || field == "POP"; }
static bool is_url(const std::string field)
{ return field[0] == 'W'; }
static bool is_text(const std::string field)
{ return field[0] == 'T' || field == "IPLS" || field == "IPL"; }
static bool is_valid(const std::string field)
{
using namespace std;
string::size_type n;
for(n = 0; n < field.length(); ++n) {
if(!isupper(field[n]) && !isdigit(field[n]))
return false;
}
return n == 3 || n == 4;
}
};
}
}
#endif