mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-14 16:39:57 +00:00
Part 1 of Data filtering, this patch adds the ability
to enter and parse filter statements in the search box
(by clicking on the magnifying glass it becomes a filter
box).
The statements can reference metrics and metadata fields
allowing the user to define boolean expressions to filter
data. An example of the syntax;
Average_Power > 200 and Duration > 3600
This references the metric Average_Power and ride Duration. But
will also support operations on metadata fields, for example;
Workout_Code endsWith "SST"
The operators are;
= <> > >= < <= matches contains endswith beginswith
( ) && and || or
Filters are syntactically and semantically validated. But at
this point the resulting tree is not evaluated, i.e. we can
parse the filters, but do not execute them.
Two further updates are pending (once written and tested):
- Part 2 of 3 : Execute filters and apply to the ride list
- Part 3 of 3 : Allow named filters and apply to LTM charts
Further updates will support a visual editor and allowing filters
to be applied to CP and Histogram charts and affect the PMC stress
calculators.
72 lines
2.8 KiB
Plaintext
72 lines
2.8 KiB
Plaintext
%{
|
|
/*
|
|
* Copyright (c) 2010 Mark Liversedge (liversedge@gmail.com)
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License as published by the Free
|
|
* Software Foundation; either version 2 of the License, or (at your option)
|
|
* any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
* more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with this program; if not, write to the Free Software Foundation, Inc., 51
|
|
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
#include "DataFilter.h"
|
|
|
|
// need to get rid of this and use a string...
|
|
#include <stdio.h>
|
|
|
|
// tokens
|
|
#include "DataFilter_yacc.h"/* generated by the scanner */
|
|
|
|
%}
|
|
%option noyywrap
|
|
%option nounput
|
|
%%
|
|
|
|
"=" DataFilterlval.op = EQ; return EQ;
|
|
"<>" DataFilterlval.op = NEQ; return NEQ;
|
|
"<" DataFilterlval.op = LT; return LT;
|
|
"<=" DataFilterlval.op = LTE; return LTE;
|
|
">" DataFilterlval.op = GT; return GT;
|
|
">=" DataFilterlval.op = GTE; return GTE;
|
|
|
|
[Mm][Aa][Tt][Cc][Hh][Ee][Ss] DataFilterlval.op = MATCHES; return MATCHES;
|
|
[Bb][Ee][Gg][Ii][Nn][Ss][Ww][Ii][Tt][Hh] DataFilterlval.op = BEGINSWITH; return BEGINSWITH;
|
|
[Ee][Nn][Dd][Ss][Ww][Ii][Tt][Hh] DataFilterlval.op = ENDSWITH; return ENDSWITH;
|
|
[Cc][Oo][Nn][Tt][Aa][Ii][Nn][Ss] DataFilterlval.op = CONTAINS; return CONTAINS;
|
|
|
|
"&&" DataFilterlval.op = AND; return AND;
|
|
[Aa][nN][Dd] DataFilterlval.op = AND; return AND;
|
|
"||" DataFilterlval.op = OR; return OR;
|
|
[Oo][Rr] DataFilterlval.op = OR; return OR;
|
|
|
|
|
|
[-+]?[0-9]+ return INTEGER;
|
|
[-+]?[0-9]+e-[0-9]+ return FLOAT;
|
|
[-+]?[0-9]+\.[-e0-9]* return FLOAT;
|
|
\"([^\"]|\\\")*\" return STRING; /* contains non-quotes or escaped-quotes */
|
|
|
|
[a-zA-Z0-9][a-zA-Z0-9_]+ return SYMBOL; /* symbols can start with 0-9 */
|
|
|
|
[ \n\t\r] ; /* we just ignore whitespace */
|
|
|
|
%%
|
|
|
|
void DataFilter_setString(QString p)
|
|
{
|
|
DataFilter_scan_string(p.toLatin1().data());
|
|
}
|
|
|
|
void DataFilter_clearString()
|
|
{
|
|
DataFilterlex_destroy();
|
|
}
|
|
|