-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsong.cpp
67 lines (62 loc) · 1.9 KB
/
song.cpp
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
#include <string.h>
#include <stdlib.h>
#include "song.hpp"
Song::Song()
: id(-1), rating(0), album_rating(0), album_rating_computed(false), play_count(0)
{
}
Song create_from_iTunes_node(const pugi::xml_node song_node)
{
Song song;
for (pugi::xml_node key = song_node.child("key"); key;
key = key.next_sibling("key"))
{
std::string keyText = key.child_value();
if (strcmp(key.child_value(), "Track ID") == 0)
{
pugi::xml_node value = key.next_sibling("integer");
song.id = atoi(value.child_value());
}
else if (strcmp(key.child_value(), "Name") == 0)
{
pugi::xml_node value = key.next_sibling("string");
song.title = value.child_value();
}
else if (strcmp(key.child_value(), "Artist") == 0)
{
pugi::xml_node value = key.next_sibling("string");
song.artist = value.child_value();
}
else if (strcmp(key.child_value(), "Album") == 0)
{
pugi::xml_node value = key.next_sibling("string");
song.album = value.child_value();
}
else if (strcmp(key.child_value(), "Play Count") == 0)
{
pugi::xml_node value = key.next_sibling("integer");
song.play_count = atoi(value.child_value());
}
else if (strcmp(key.child_value(), "Rating") == 0)
{
pugi::xml_node value = key.next_sibling("integer");
song.rating = atoi(value.child_value());
}
else if (strcmp(key.child_value(), "Album Rating") == 0)
{
pugi::xml_node value = key.next_sibling("integer");
song.album_rating = atoi(value.child_value());
}
else if (strcmp(key.child_value(), "Album Rating Computed") == 0)
{
pugi::xml_node value = key.next_sibling("true");
song.album_rating_computed = value;
}
else if (strcmp(key.child_value(), "Location") == 0)
{
pugi::xml_node value = key.next_sibling("string");
song.file_name = value.child_value();
}
}
return song;
}