1 #include <vector>
2 #include <memory>
3 #include <new>
4 #include <cstdio>
5 #include <cstring>
6 #include <cstdlib>
7 #include "lyrics3.h"
8 #include "getid3.h"
9 #include "getlyr3.h"
10 
11 /*
12 
13   copyright (c) 2006 squell <squell@alumina.nl>
14 
15   use, modification, copying and distribution of this software is permitted
16   under the conditions described in the file 'COPYING'.
17 
18 */
19 
20 using namespace std;
21 using namespace charset;
22 
23 using tag::read::Lyrics3;
24 using tag::ID3field;
25 
Lyrics3(const char * fn)26 Lyrics3::Lyrics3(const char* fn)
27 : ID3(fn), lyrics_tag(lyrics3::read(fn,0))
28 {
29 }
30 
31 const char Lyrics3::field_name[3][4] = { "ETT", "EAR", "EAL" };
32 
operator [](ID3field field) const33 Lyrics3::value_string Lyrics3::operator[](ID3field field) const
34 {
35     const value_string& id3 = ID3::operator[](field);
36     const char (*ptr)[4] = field_name;
37     switch(field) {
38     case tag::FIELD_MAX:
39         return "Lyrics3v2.0";
40     default:
41         return id3;
42     case tag::album:  ++ptr;
43     case tag::artist: ++ptr;
44     case tag::title:
45         value_string lyr3 = lyrics3::find(lyrics_tag, *ptr);
46         return (lyr3.substr(0, id3.length()) == id3)? lyr3 : id3;
47     }
48 }
49 
50 /* ====================================================== */
51 
listing() const52 Lyrics3::array Lyrics3::listing() const
53 {
54     lyrics3::info s = lyrics_tag;
55     string::size_type i, next;
56     array vec;
57 
58     vec.push_back( array::value_type("Lyrics3", "2.0") );
59     for(i = 0; next=find_next(s, i); i = next)
60         vec.push_back( array::value_type(s.id(i), s.content(i, next - i)) );
61 
62     return vec;
63 }
64 
65