blob: 79c646dbf7b54f23c757b669e910413cacd1d9de (
plain)
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
|
/*
* parser.h
*
* Created on: 16.09.2012
* Author: savop
*/
#ifndef PARSER_H_
#define PARSER_H_
#include <map>
#include <string>
#include <sstream>
#include <list>
#include "../include/tools.h"
using namespace std;
namespace upnp {
/**
* Sort criteria
*
* This is a structure for sorting objects. It has a certain property and
* a direction flag.
*/
struct SortCrit {
string property; ///< the Property, which shall be sorted
bool sortDescending; ///< sort the objects in descending order
};
//typedef std::map<const char*, const char*, strCmp> propertyMap;
/**
* 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 {
public:
typedef list<SortCrit> SortCriteriaList;
private:
SortCrit mCurrentCrit;
SortCriteriaList mCriteriaList;
bool parseSort(string sort);
void pushProperty(string property);
void pushDirection(bool desc);
SortCriteriaList 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 SortCriteriaList parse(
const string& 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:
StringList mFilterList;
cFilterCriteria();
bool parseFilter(string filter);
void pushProperty(const char* start, const char* end);
void pushAsterisk(const char asterisk);
StringList 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 StringList parse(
const string& Filter = "*" ///< the filter string
);
};
/**
* @private
*/
class cSearch {
private:
stringstream sqlWhereStmt;
string currentProperty;
string currentOperator;
string currentValue;
cSearch();
bool parseCriteria(string Search);
void pushExistance (string Exists);
void pushProperty (string Property);
void pushOperator (string Operator);
void pushConcatOp (string 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 string parse(const string& Search);
};
} // namespace upnp
#endif /* PARSER_H_ */
|