3 $Date: 2010/10/04 20:26:10 $
13 #include "resetable.h"
14 #include "stg_const.h"
15 #include "base_store.h"
16 #include "../../../admins.h"
17 #include "../../../users.h"
18 #include "stg_message.h"
22 //-----------------------------------------------------------------------------
35 virtual ~BASE_PARSER() {};
36 virtual int ParseStart(void *data, const char *el, const char **attr) = 0;
37 virtual int ParseEnd(void *data, const char *el) = 0;
38 virtual void CreateAnswer() = 0;
39 virtual void SetAnswerList(list<string> * ansList) { answerList = ansList; };
41 virtual void SetUsers(USERS * u) { users = u; };
42 virtual void SetAdmins(ADMINS * a) { admins = a; };
43 virtual void SetTariffs(TARIFFS * t) { tariffs = t; };
44 virtual void SetStore(BASE_STORE * s) { store = s; };
45 virtual void SetStgSettings(const SETTINGS * s) { settings = s; };
47 virtual void SetCurrAdmin(const ADMIN & cua) { currAdmin = cua; };
48 virtual string & GetStrError(){return strError;};
49 virtual void Reset(){ answerList->clear(); depth = 0; };
56 const SETTINGS * settings;
59 list<string> * answerList;
61 //-----------------------------------------------------------------------------
62 class PARSER_GET_ADMINS: public BASE_PARSER
65 int ParseStart(void *data, const char *el, const char **attr);
66 int ParseEnd(void *data, const char *el);
69 //-----------------------------------------------------------------------------
70 class PARSER_ADD_ADMIN: public BASE_PARSER
73 PARSER_ADD_ADMIN() : BASE_PARSER() {}
74 int ParseStart(void *data, const char *el, const char **attr);
75 int ParseEnd(void *data, const char *el);
80 //-----------------------------------------------------------------------------
81 class PARSER_DEL_ADMIN: public BASE_PARSER
84 PARSER_DEL_ADMIN() : BASE_PARSER() {}
85 int ParseStart(void *data, const char *el, const char **attr);
86 int ParseEnd(void *data, const char *el);
89 int CheckAttr(const char **attr);
92 //-----------------------------------------------------------------------------
93 class PARSER_CHG_ADMIN: public BASE_PARSER
96 PARSER_CHG_ADMIN() : BASE_PARSER() {}
97 int ParseStart(void *data, const char *el, const char **attr);
98 int ParseEnd(void *data, const char *el);
101 RESETABLE<string> login;
102 RESETABLE<string> password;
103 RESETABLE<string> privAsString;
105 //-----------------------------------------------------------------------------
106 class PARSER_GET_SERVER_INFO: public BASE_PARSER
109 int ParseStart(void *data, const char *el, const char **attr);
110 int ParseEnd(void *data, const char *el);
114 //-----------------------------------------------------------------------------
115 class PARSER_GET_USER: public BASE_PARSER
119 ~PARSER_GET_USER(){};
120 int ParseStart(void *data, const char *el, const char **attr);
121 int ParseEnd(void *data, const char *el);
126 //-----------------------------------------------------------------------------
127 class PARSER_GET_USERS: public BASE_PARSER
131 int ParseStart(void *data, const char *el, const char **attr);
132 int ParseEnd(void *data, const char *el);
135 time_t lastUserUpdateTime;
136 bool lastUpdateFound;
138 //-----------------------------------------------------------------------------
139 class PARSER_GET_TARIFFS: public BASE_PARSER
142 int ParseStart(void *data, const char *el, const char **attr);
143 int ParseEnd(void *data, const char *el);
146 //-----------------------------------------------------------------------------
147 class PARSER_ADD_TARIFF: public BASE_PARSER
150 PARSER_ADD_TARIFF() : BASE_PARSER() {}
151 int ParseStart(void *data, const char *el, const char **attr);
152 int ParseEnd(void *data, const char *el);
157 //-----------------------------------------------------------------------------
158 class PARSER_DEL_TARIFF: public BASE_PARSER
161 PARSER_DEL_TARIFF() : BASE_PARSER() {}
162 int ParseStart(void *data, const char *el, const char **attr);
163 int ParseEnd(void *data, const char *el);
168 //-----------------------------------------------------------------------------
169 class PARSER_CHG_TARIFF: public BASE_PARSER
172 PARSER_CHG_TARIFF() : BASE_PARSER() {}
173 int ParseStart(void *data, const char *el, const char **attr);
174 int ParseEnd(void *data, const char *el);
177 int ParseSlashedIntParams(int paramsNum, const string & s, int * params);
178 int ParseSlashedDoubleParams(int paramsNum, const string & s, double * params);
179 int CheckTariffData();
184 //-----------------------------------------------------------------------------/
185 class PARSER_ADD_USER: public BASE_PARSER
189 ~PARSER_ADD_USER(){};
190 int ParseStart(void *data, const char *el, const char **attr);
191 int ParseEnd(void *data, const char *el);
198 //-----------------------------------------------------------------------------
199 class PARSER_CHG_USER: public BASE_PARSER
204 int ParseStart(void *data, const char *el, const char **attr);
205 int ParseEnd(void *data, const char *el);
209 string EncChar2String(const char *);
215 RESETABLE<uint64_t> * upr;
216 RESETABLE<uint64_t> * downr;
219 bool cashMustBeAdded;
222 //-----------------------------------------------------------------------------
223 class PARSER_DEL_USER: public BASE_PARSER
226 PARSER_DEL_USER() : BASE_PARSER(), res(0) {}
227 int ParseStart(void *data, const char *el, const char **attr);
228 int ParseEnd(void *data, const char *el);
235 //-----------------------------------------------------------------------------
236 class PARSER_CHECK_USER: public BASE_PARSER
239 PARSER_CHECK_USER() : BASE_PARSER(), result(false) {}
240 int ParseStart(void *data, const char *el, const char **attr);
241 int ParseEnd(void *data, const char *el);
246 //-----------------------------------------------------------------------------
247 class PARSER_SEND_MESSAGE: public BASE_PARSER
250 PARSER_SEND_MESSAGE() : BASE_PARSER(), result(0) {}
251 int ParseStart(void *data, const char *el, const char **attr);
252 int ParseEnd(void *data, const char *el);
255 int ParseLogins(const char * logins);
257 enum {res_ok, res_params_error, res_unknown};
258 vector<string> logins;
263 //-----------------------------------------------------------------------------