3 $Date: 2009/07/30 18:57:37 $
15 #include "resetable.h"
16 #include "stg_const.h"
17 #include "base_store.h"
18 #include "../../../admins.h"
19 #include "../../../users.h"
20 #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;
57 const ADMIN * currAdmin;
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 int ParseStart(void *data, const char *el, const char **attr);
74 int ParseEnd(void *data, const char *el);
79 //-----------------------------------------------------------------------------
80 class PARSER_DEL_ADMIN: public BASE_PARSER
83 int ParseStart(void *data, const char *el, const char **attr);
84 int ParseEnd(void *data, const char *el);
87 int CheckAttr(const char **attr);
90 //-----------------------------------------------------------------------------
91 class PARSER_CHG_ADMIN: public BASE_PARSER
94 int ParseStart(void *data, const char *el, const char **attr);
95 int ParseEnd(void *data, const char *el);
98 RESETABLE<string> login;
99 RESETABLE<string> password;
100 RESETABLE<string> privAsString;
102 //-----------------------------------------------------------------------------
103 class PARSER_GET_SERVER_INFO: public BASE_PARSER
106 int ParseStart(void *data, const char *el, const char **attr);
107 int ParseEnd(void *data, const char *el);
111 //-----------------------------------------------------------------------------
112 class PARSER_GET_USER: public BASE_PARSER
116 ~PARSER_GET_USER(){};
117 int ParseStart(void *data, const char *el, const char **attr);
118 int ParseEnd(void *data, const char *el);
123 //-----------------------------------------------------------------------------
124 class PARSER_GET_USERS: public BASE_PARSER
128 int ParseStart(void *data, const char *el, const char **attr);
129 int ParseEnd(void *data, const char *el);
132 time_t lastUserUpdateTime;
133 bool lastUpdateFound;
135 //-----------------------------------------------------------------------------
136 class PARSER_GET_TARIFFS: public BASE_PARSER
139 int ParseStart(void *data, const char *el, const char **attr);
140 int ParseEnd(void *data, const char *el);
143 //-----------------------------------------------------------------------------
144 class PARSER_ADD_TARIFF: public BASE_PARSER
147 int ParseStart(void *data, const char *el, const char **attr);
148 int ParseEnd(void *data, const char *el);
153 //-----------------------------------------------------------------------------
154 class PARSER_DEL_TARIFF: public BASE_PARSER
157 int ParseStart(void *data, const char *el, const char **attr);
158 int ParseEnd(void *data, const char *el);
163 //-----------------------------------------------------------------------------
164 class PARSER_CHG_TARIFF: public BASE_PARSER
167 int ParseStart(void *data, const char *el, const char **attr);
168 int ParseEnd(void *data, const char *el);
171 int ParseSlashedIntParams(int paramsNum, const string & s, int * params);
172 int ParseSlashedDoubleParams(int paramsNum, const string & s, double * params);
173 int CheckTariffData();
178 //-----------------------------------------------------------------------------/
179 class PARSER_ADD_USER: public BASE_PARSER
183 virtual ~PARSER_ADD_USER(){};
184 int ParseStart(void *data, const char *el, const char **attr);
185 int ParseEnd(void *data, const char *el);
192 //-----------------------------------------------------------------------------
193 class PARSER_CHG_USER: public BASE_PARSER
198 int ParseStart(void *data, const char *el, const char **attr);
199 int ParseEnd(void *data, const char *el);
203 string EncChar2String(const char *);
207 RESETABLE<uint64_t> * upr;
208 RESETABLE<uint64_t> * downr;
214 bool cashMustBeAdded;
217 //-----------------------------------------------------------------------------
218 class PARSER_DEL_USER: public BASE_PARSER
221 int ParseStart(void *data, const char *el, const char **attr);
222 int ParseEnd(void *data, const char *el);
229 //-----------------------------------------------------------------------------
230 class PARSER_CHECK_USER: public BASE_PARSER
233 int ParseStart(void *data, const char *el, const char **attr);
234 int ParseEnd(void *data, const char *el);
239 //-----------------------------------------------------------------------------
240 class PARSER_SEND_MESSAGE: public BASE_PARSER
243 int ParseStart(void *data, const char *el, const char **attr);
244 int ParseEnd(void *data, const char *el);
247 enum {res_ok, res_params_error, res_unknown};
248 vector<string> logins;
249 int ParseLogins(const char * logins);
254 //-----------------------------------------------------------------------------