blob: d588c5f263dd1a7b48ae377dd75978719e9e5d36 (
plain)
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
#include "XmlObject.h"
#include <vdr/tools.h>
namespace plexclient
{
std::string XmlObject::GetNodeValue(Poco::XML::Node* pNode)
{
std::string value;
if(pNode != 0) {
value = pNode->getNodeValue();
}
return value;
}
int XmlObject::GetNodeValueAsInt(Poco::XML::Node* pNode)
{
int value = -1;
if(pNode != 0) {
try {
value = atoi(pNode->getNodeValue().c_str());
} catch(Poco::Exception) {}
}
return value;
}
long XmlObject::GetNodeValueAsLong(Poco::XML::Node* pNode)
{
long value = -1;
if(pNode != 0) {
try {
value = atol(pNode->getNodeValue().c_str());
} catch(Poco::Exception) {}
}
return value;
}
double XmlObject::GetNodeValueAsDouble(Poco::XML::Node* pNode)
{
double value = -1;
if(pNode != 0) {
try {
value = atod(pNode->getNodeValue().c_str());
} catch(Poco::Exception) {}
}
return value;
}
bool XmlObject::GetNodeValueAsBool(Poco::XML::Node* pNode)
{
bool value = false;
if(pNode != 0) {
value = pNode->getNodeValue() == "1";
}
return value;
}
Poco::Timestamp XmlObject::GetNodeValueAsTimeStamp(Poco::XML::Node* pNode)
{
Poco::Timestamp value;
if(pNode != 0) {
try {
long lValue = atol(pNode->nodeValue().c_str());
value = Poco::Timestamp(lValue);
} catch (Poco::Exception) {}
}
return value;
}
MediaType XmlObject::GetNodeValueAsMediaType(Poco::XML::Node* pNode)
{
MediaType type = UNDEF;
if(pNode != 0) {
std::string sType = pNode->nodeValue();
if (Poco::icompare(sType, "photo") == 0) {
type = PHOTO;
} else if (Poco::icompare(sType, "movie") == 0) {
type = MOVIE;
} else if (Poco::icompare(sType, "music") == 0) {
type = MUSIC;
} else if (Poco::icompare(sType, "show") == 0) {
type = SHOW;
} else if (Poco::icompare(sType, "season") == 0) {
type = SEASON;
} else if (Poco::icompare(sType, "episode") == 0) {
type = EPISODE;
}
}
return type;
}
StreamType XmlObject::GetNodeValueAsStreamType(Poco::XML::Node* pNode)
{
StreamType type = sUNDEF;
if(pNode != 0) {
int iType = GetNodeValueAsInt(pNode);
switch(iType) {
case 1: type = sVIDEO; break;
case 2: type = sAUDIO; break;
case 3: type = sSUBTITLE; break;
default: type = sUNDEF; break;
}
}
return type;
}
}
|