From 68ac6628a31cb1472275b5282c5cf9a971d9bddd Mon Sep 17 00:00:00 2001 From: mrwastl Date: Sat, 17 Apr 2010 19:16:26 +0200 Subject: backport of skin-support from 0.2.x to 0.1.x, changes for gcc 4.3 conformity --- glcdskin/variable.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 glcdskin/variable.c (limited to 'glcdskin/variable.c') diff --git a/glcdskin/variable.c b/glcdskin/variable.c new file mode 100644 index 0000000..b07773a --- /dev/null +++ b/glcdskin/variable.c @@ -0,0 +1,74 @@ +#include + +#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 -- cgit v1.2.3