1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
/*
* File: search.h
* Author: savop
*
* Created on 27. August 2009, 21:21
*/
#ifndef _SEARCH_H
#define _SEARCH_H
#include <map>
#include <vdr/tools.h>
#include "util.h"
/**
* Sort criteria
*
* This is a structure for sorting objects. It has a certain property and
* a direction flag.
*/
struct cSortCrit : public cListObject {
const char* Property; ///< the Property, which shall be sorted
bool SortDescending; ///< sort the objects in descending order
};
typedef std::map<const char*, const char*, strCmp> propertyMap;
/**
* Web path parser
*
* Parses paths which came from the webserver. It splits the path into
* a section, a certain method and its properties.
*
* This can be used to easily determine which file was requested by a client
*/
class cPathParser {
private:
cString mKey;
propertyMap mProperties;
int mSection;
int mMethod;
bool parsePath(const char* Path, int* Section, int* Method, propertyMap* Properties);
void pushPropertyKey(const char* Start, const char* End);
void pushPropertyValue(const char* Start, const char* End);
void pushMethod(int Method);
void pushSection(int Section);
cPathParser();
public:
virtual ~cPathParser();
/**
* Parses the path
*
* This will parse the path and stores the result in the pointers given.
*
* @return returns
* - \bc true, if the parsing was successful
* - \bc false, otherwise
*/
static bool parse(
const char* Path, ///< the path which is parsed
int* Section, ///< the number of the registered section
int* Method, ///< the number of the registered method
propertyMap* Properties ///< the properties found in the path
);
};
/**
* Creates a list with sort criteria
*
* This parser creates a list of sort criteria. It parses the sort criteria string
* from a \em Browse or \em Search request and stores the information in a \c cSortCrit
* structure.
*/
class cSortCriteria {
private:
cSortCrit* mCurrentCrit;
cList<cSortCrit>* mCriteriaList;
bool parseSort(const char* Sort);
void pushProperty(const char* Property);
void pushDirection(const char Direction);
cList<cSortCrit>* getSortList() const { return this->mCriteriaList; }
cSortCriteria();
public:
virtual ~cSortCriteria();
/**
* Parses the sort criteria
*
* This parses the sort criteria and returns a list with valid criterias
*
* @return returns
* - a list with valid sort criterias
* - \bc null, otherwise
*/
static cList<cSortCrit>* parse(
const char* Sort ///< the string container the sort criteria
);
};
/**
* Parses the filter criteria
*
* This parses the filter criteria which comes from a \em Browse or \em Search
* request.
*/
class cFilterCriteria {
private:
cStringList* mFilterList;
cFilterCriteria();
bool parseFilter(const char* Filter);
void pushProperty(const char* Property);
void pushAsterisk(const char Asterisk);
cStringList* getFilterList() const { return this->mFilterList; }
public:
virtual ~cFilterCriteria();
/**
* Parses the filter criteria
*
* This parses the filter criteria. It may be a empty string list, a \bc NULL
* pointer or a list with properties which shall be shown in the \em DIDL-Lite fragment.
*
* @return the stringlist containing the filter
*/
static cStringList* parse(
const char* Filter ///< the filter string
);
};
/**
* @private
* @todo This is implemented very soon
*/
class cSearch {
private:
char* SQLWhereStmt;
const char* CurrentProperty;
const char* CurrentOperator;
const char* CurrentValue;
static cSearch* mInstance;
cSearch();
bool parseCriteria(const char* Search);
void pushExistance (const char* Exists);
void pushProperty (const char* Property);
void pushOperator (const char* Operator);
void pushConcatOp (const char* Operator);
void pushStartBrackedExp(const char);
void pushEndBrackedExp(const char);
void pushValue (const char* Start, const char* End);
void pushExpression(const char* Start, const char* End);
public:
virtual ~cSearch();
static const char* parse(const char* Search);
};
#endif /* _SEARCH_H */
|