unsigned i;
for(i=0;i<strlen(expression);i++) {
-
}
}
gpointer tree;
- GString *currentOption = g_string_new("");
-
+ GString *current_option = g_string_new("");
+ lttv_simple_expression current_expression;
+
g_print("filter::lttv_filter_new()\n"); /* debug */
/*
/*
* Parse entire expression and construct
- * the binary tree
+ * the binary tree. There are two steps
+ * in browsing that string
+ * 1. finding boolean ops ( &,|,^,! ) and parenthesis
+ * 2. finding simple expressions
+ * - field path
+ * - op ( >, <, =, >=, <=, !=)
+ * - value
*/
for(i=0;i<strlen(expression);i++) {
switch(expression[i]) {
+ /*
+ * boolean operators
+ */
case '&': /* and */
parse_simple_expression(currentOption);
g_print("%s\n",¤tOption);
g_print("%s\n",currentOption);
currentOption = g_string_new("");
break;
- case '!': /* not */
- g_print("%s\n",currentOption);
- currentOption = g_string_new("");
- break;
+ case '!': /* not, or not equal (math op) */
+ if(expression[i+1] == '=') { /* != */
+ current_expression.op = LTTV_FIELD_NE;
+ i++;
+ } else { /* ! */
+ g_print("%s\n",currentOption);
+ currentOption = g_string_new("");
+ }
+ break;
case '(': /* start of parenthesis */
p++;
break;
case ')': /* end of parenthesis */
p--;
break;
+ /*
+ * mathematic operators
+ */
+ case '<': /* lower, lower or equal */
+ if(expression[i+1] == '=') { /* <= */
+ i++;
+ current_expression.op = LTTV_FIELD_LE;
+ } else current_expression.op = LTTV_FIELD_LT;
+ break;
+ case '>': /* higher, higher or equal */
+ if(expression[i+1] == '=') { /* >= */
+ i++;
+ current_expression.op = LTTV_FIELD_GE;
+ } else current_expression.op = LTTV_FIELD_GT;
+ break;
+ case '=': /* equal */
+ current_expression.op = LTTV_FIELD_EQ;
+ break;
+ case
default: /* concatening current string */
g_string_append_c(currentOption,expression[i]);
}