00001
00002
00003
00004
00005
00006
00007
00008 #ifndef _SEARCH_H
00009 #define _SEARCH_H
00010
00011 #include <map>
00012 #include <vdr/tools.h>
00013 #include "util.h"
00014
00021 struct cSortCrit : public cListObject {
00022 const char* Property;
00023 bool SortDescending;
00024 };
00025
00026 typedef std::map<const char*, const char*, strCmp> propertyMap;
00027
00036 class cPathParser {
00037 private:
00038 cString mKey;
00039 propertyMap mProperties;
00040 int mSection;
00041 int mMethod;
00042 bool parsePath(const char* Path, int* Section, int* Method, propertyMap* Properties);
00043 void pushPropertyKey(const char* Start, const char* End);
00044 void pushPropertyValue(const char* Start, const char* End);
00045 void pushMethod(int Method);
00046 void pushSection(int Section);
00047 cPathParser();
00048 public:
00049 virtual ~cPathParser();
00059 static bool parse(
00060 const char* Path,
00061 int* Section,
00062 int* Method,
00063 propertyMap* Properties
00064 );
00065 };
00066
00074 class cSortCriteria {
00075 private:
00076 cSortCrit* mCurrentCrit;
00077 cList<cSortCrit>* mCriteriaList;
00078 bool parseSort(const char* Sort);
00079 void pushProperty(const char* Property);
00080 void pushDirection(const char Direction);
00081 cList<cSortCrit>* getSortList() const { return this->mCriteriaList; }
00082 cSortCriteria();
00083 public:
00084 virtual ~cSortCriteria();
00094 static cList<cSortCrit>* parse(
00095 const char* Sort
00096 );
00097 };
00098
00105 class cFilterCriteria {
00106 private:
00107 cStringList* mFilterList;
00108 cFilterCriteria();
00109 bool parseFilter(const char* Filter);
00110 void pushProperty(const char* Property);
00111 void pushAsterisk(const char Asterisk);
00112 cStringList* getFilterList() const { return this->mFilterList; }
00113 public:
00114 virtual ~cFilterCriteria();
00123 static cStringList* parse(
00124 const char* Filter
00125 );
00126 };
00127
00132 class cSearch {
00133 private:
00134 char* SQLWhereStmt;
00135 const char* CurrentProperty;
00136 const char* CurrentOperator;
00137 const char* CurrentValue;
00138 static cSearch* mInstance;
00139 cSearch();
00140 bool parseCriteria(const char* Search);
00141 void pushExistance (const char* Exists);
00142 void pushProperty (const char* Property);
00143 void pushOperator (const char* Operator);
00144 void pushConcatOp (const char* Operator);
00145 void pushStartBrackedExp(const char);
00146 void pushEndBrackedExp(const char);
00147 void pushValue (const char* Start, const char* End);
00148 void pushExpression(const char* Start, const char* End);
00149 public:
00150 virtual ~cSearch();
00151 static const char* parse(const char* Search);
00152 };
00153
00154
00155 #endif
00156