summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlordjaxom <lordjaxom>2005-01-07 21:49:55 +0000
committerlordjaxom <lordjaxom>2005-01-07 21:49:55 +0000
commite5b5bd85f617619b79c284671f5ba1feb207815c (patch)
tree8ffeaa6dd3b8e8ed1fbe053a1b8dee265dcd6429
parent62ad3100d861a1227fe4c1130dcf2a7ec096ed61 (diff)
downloadvdr-plugin-text2skin-e5b5bd85f617619b79c284671f5ba1feb207815c.tar.gz
vdr-plugin-text2skin-e5b5bd85f617619b79c284671f5ba1feb207815c.tar.bz2
- implemented functions gt, lt, ge and le
-rw-r--r--xml/function.c42
-rw-r--r--xml/function.h24
2 files changed, 49 insertions, 17 deletions
diff --git a/xml/function.c b/xml/function.c
index 64d853e..f8a447d 100644
--- a/xml/function.c
+++ b/xml/function.c
@@ -1,5 +1,5 @@
/*
- * $Id: function.c,v 1.7 2005/01/05 19:32:43 lordjaxom Exp $
+ * $Id: function.c,v 1.8 2005/01/07 21:49:55 lordjaxom Exp $
*/
#include "xml/function.h"
@@ -10,12 +10,9 @@
#include <vdr/tools.h>
static const char *Internals[] = {
- "not", "and", "or", "equal", "file", "trans", "plugin", NULL
+ "not", "and", "or", "equal", "file", "trans", "plugin", "gt", "lt", "ge", "le", NULL
};
-const std::string cxFunction::False = "";
-const std::string cxFunction::True = "1";
-
cxFunction::cxFunction(cxSkin *Skin):
mSkin(Skin),
mType(string),
@@ -81,6 +78,18 @@ bool cxFunction::Parse(const std::string &Text)
mType = string;
}
+ else if ((*ptr >= '0' && *ptr <= '9') || *ptr == '-' || *ptr == '+') {
+ // must be number
+ char *end;
+ int num = strtol(ptr, &end, 10);
+ if (end == ptr || *end != '\0') {
+ esyslog("ERROR: Invalid numeric value\n");
+ return false;
+ }
+
+ mNumber = num;
+ mType = number;
+ }
else {
// expression
for (; *ptr; ++ptr) {
@@ -134,7 +143,11 @@ bool cxFunction::Parse(const std::string &Text)
case fun_and:
case fun_or: params = -1; break;
- case fun_eq: ++params;
+ case fun_eq:
+ case fun_gt:
+ case fun_lt:
+ case fun_ge:
+ case fun_le: ++params;
case fun_not:
case fun_trans:
case fun_plugin:
@@ -189,6 +202,9 @@ cxType cxFunction::Evaluate(void) const
case string:
return mString.Evaluate();
+ case number:
+ return mNumber;
+
case fun_not:
return !mParams[0]->Evaluate();
@@ -209,6 +225,18 @@ cxType cxFunction::Evaluate(void) const
case fun_eq:
return mParams[0]->Evaluate() == mParams[1]->Evaluate();
+ case fun_gt:
+ return mParams[0]->Evaluate() > mParams[1]->Evaluate();
+
+ case fun_lt:
+ return mParams[0]->Evaluate() < mParams[1]->Evaluate();
+
+ case fun_ge:
+ return mParams[0]->Evaluate() >= mParams[1]->Evaluate();
+
+ case fun_le:
+ return mParams[0]->Evaluate() <= mParams[1]->Evaluate();
+
case fun_file:
return FunFile(mParams[0]->Evaluate());
@@ -225,7 +253,7 @@ cxType cxFunction::Evaluate(void) const
esyslog("ERROR: Unknown function code called (this shouldn't happen)");
break;
}
- return False;
+ return false;
}
#if 0
diff --git a/xml/function.h b/xml/function.h
index afc3465..0e0a194 100644
--- a/xml/function.h
+++ b/xml/function.h
@@ -1,5 +1,5 @@
/*
- * $Id: function.h,v 1.5 2005/01/05 19:32:43 lordjaxom Exp $
+ * $Id: function.h,v 1.6 2005/01/07 21:50:27 lordjaxom Exp $
*/
#ifndef VDR_TEXT2SKIN_XML_FUNCTION_H
@@ -22,17 +22,21 @@ public:
string = STRING,
number = NUMBER,
- fun_not = INTERNAL + 1,
- fun_and = INTERNAL + 2,
- fun_or = INTERNAL + 3,
- fun_eq = INTERNAL + 4,
- fun_file = INTERNAL + 5,
- fun_trans = INTERNAL + 6,
- fun_plugin = INTERNAL + 7
+ fun_not = INTERNAL + 1,
+ fun_and = INTERNAL + 2,
+ fun_or = INTERNAL + 3,
+ fun_eq = INTERNAL + 4,
+ fun_file = INTERNAL + 5,
+ fun_trans = INTERNAL + 6,
+ fun_plugin = INTERNAL + 7,
+ fun_gt = INTERNAL + 8,
+ fun_lt = INTERNAL + 9,
+ fun_ge = INTERNAL + 10,
+ fun_le = INTERNAL + 11,
};
- static const std::string False;
- static const std::string True;
+ //static const std::string False;
+ //static const std::string True;
private:
cxSkin *mSkin;