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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
/*! \file mg_filters.h
* \brief Top level access to media in vdr plugin muggle
* for the vdr muggle plugindatabase
*
* \version $Revision: 1.2 $
* \date $Date$
* \author Ralf Klueber, Lars von Wedel, Andreas Kellner
* \author file owner: $Author$
*/
#ifndef _MG_FILTERS_H
#define _MG_FILTERS_H
#include <string>
#include <vector>
/*!
* \brief abstract base class for representation of filter values with boundaries
*/
class mgFilter
{
public:
typedef enum filterType
{
UNDEF = 0,
INT,
STRING,
BOOL,
CHOICE
} filterType;
protected:
filterType m_type;
char* m_name;
public:
mgFilter(const char* name);
virtual ~mgFilter();
filterType getType();
const char* getName();
virtual std::string getStrVal() = 0;
virtual int getIntVal()
{ return 0; }
virtual void store() = 0;
virtual void restore() = 0;
virtual void clear() = 0;
virtual bool isSet() = 0;
};
/*!
* \class mgFilterInt
*/
class mgFilterInt : public mgFilter
{
private:
int m_min;
int m_max;
int m_stored_val;
int m_default_val;
public:
int m_intval;
mgFilterInt(const char *name, int value, int min = 0, int max = 9999);
virtual ~mgFilterInt();
int getVal();
int getMin();
int getMax();
virtual std::string getStrVal();
virtual int getIntVal();
virtual void store();
virtual void restore();
virtual void clear();
virtual bool isSet();
};
/*!
* \class mgFilterString
*/
class mgFilterString : public mgFilter
{
private:
std::string m_allowedchar;
int m_maxlen;
char* m_stored_val;
char* m_default_val;
public:
char* m_strval;
mgFilterString(const char *name, const char* value, int maxlen=255,
std::string allowedchar="abcdefghijklmnopqrstuvwxyz0123456789-");
virtual ~mgFilterString();
int getMaxLength();
std::string getAllowedChars();
virtual std::string getStrVal();
virtual void store();
virtual void restore();
virtual void clear();
virtual bool isSet();
};
/*!
* \class mgFilterBool
*/
class mgFilterBool : public mgFilter
{
private:
std::string m_truestr;
std::string m_falsestr;
bool m_stored_val;
bool m_default_val;
public:
int m_bval;
mgFilterBool(const char *name, bool value,
std::string truestr="yes", std::string falsestr="no");
virtual ~mgFilterBool();
virtual std::string getStrVal();
virtual int getIntVal();
std::string getTrueString();
std::string getFalseString();
bool getVal();
virtual void store();
virtual void restore();
virtual void clear();
virtual bool isSet();
};
/*!
* \class mgFilterChoice
*/
class mgFilterChoice : public mgFilter
{
private:
std::vector<std::string> m_choices;
int m_stored_val;
int m_default_val;
public:
int m_selval; // index of the currently selected item
mgFilterChoice(const char *name, int val, std::vector<std::string> *choices);
virtual ~mgFilterChoice();
virtual std::string getStrVal();
virtual std::vector<std::string> &getChoices();
virtual void store();
virtual void restore();
virtual void clear();
virtual bool isSet();
};
#endif
|