blob: b07773a3fe9cb7057f28120eacbbceebd9eec743 (
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
|
#include <syslog.h>
#include "variable.h"
#include "skin.h"
#include "function.h"
namespace GLCD
{
cSkinVariable::cSkinVariable(cSkin * Parent)
: mSkin(Parent),
mValue(0),
mCondition(NULL),
mDummyDisplay(mSkin),
mDummyObject(&mDummyDisplay)
{
}
bool cSkinVariable::ParseValue(const std::string & Text)
{
if (isalpha(Text[0]) || Text[0] == '#')
{
cSkinFunction * func = new cSkinFunction(&mDummyObject);
if (func->Parse(Text))
{
mValue = func->Evaluate();
delete func;
return true;
}
delete func;
}
else if (Text[0] == '\'')
{
mValue = Text.substr(1, Text.length() - 2);
return true;
}
char * e;
const char * t = Text.c_str();
long l = strtol(t, &e, 10);
if (e == t || *e != '\0')
{
return false;
}
mValue = l;
return true;
}
bool cSkinVariable::ParseCondition(const std::string & Text)
{
cSkinFunction *result = new cSkinFunction(&mDummyObject);
if (result->Parse(Text))
{
delete mCondition;
mCondition = result;
return true;
}
return false;
}
cSkinVariables::cSkinVariables(void)
{
}
cSkinVariables::~cSkinVariables()
{
iterator it = begin();
while (it != end())
{
delete (*it);
it++;
}
}
} // end of namespace
|