3 $Date: 2009/07/30 18:57:37 $
15 #include "resetable.h"
22 //-----------------------------------------------------------------------------
34 virtual ~BASE_PARSER() {}
35 virtual int ParseStart(void *data, const char *el, const char **attr) = 0;
36 virtual int ParseEnd(void *data, const char *el) = 0;
37 virtual void CreateAnswer() = 0;
38 virtual void SetAnswerList(list<string> * ansList) { answerList = ansList; }
40 virtual void SetUsers(USERS * u) { users = u; }
41 virtual void SetAdmins(ADMINS * a) { admins = a; }
42 virtual void SetTariffs(TARIFFS * t) { tariffs = t; }
43 virtual void SetStore(STORE * s) { store = s; }
44 virtual void SetStgSettings(const SETTINGS * s) { settings = s; }
46 virtual void SetCurrAdmin(const ADMIN * cua) { currAdmin = cua; }
47 virtual string & GetStrError() { return strError; }
48 virtual void Reset(){ answerList->clear(); depth = 0; }
55 const SETTINGS * settings;
56 const ADMIN * currAdmin;
58 list<string> * answerList;
60 //-----------------------------------------------------------------------------
61 class PARSER_GET_ADMINS: public BASE_PARSER {
63 int ParseStart(void *data, const char *el, const char **attr);
64 int ParseEnd(void *data, const char *el);
67 //-----------------------------------------------------------------------------
68 class PARSER_ADD_ADMIN: public BASE_PARSER {
70 int ParseStart(void *data, const char *el, const char **attr);
71 int ParseEnd(void *data, const char *el);
76 //-----------------------------------------------------------------------------
77 class PARSER_DEL_ADMIN: public BASE_PARSER {
79 int ParseStart(void *data, const char *el, const char **attr);
80 int ParseEnd(void *data, const char *el);
83 int CheckAttr(const char **attr);
86 //-----------------------------------------------------------------------------
87 class PARSER_CHG_ADMIN: public BASE_PARSER {
89 int ParseStart(void *data, const char *el, const char **attr);
90 int ParseEnd(void *data, const char *el);
93 RESETABLE<string> login;
94 RESETABLE<string> password;
95 RESETABLE<string> privAsString;
97 //-----------------------------------------------------------------------------
98 class PARSER_GET_SERVER_INFO: public BASE_PARSER {
100 int ParseStart(void *data, const char *el, const char **attr);
101 int ParseEnd(void *data, const char *el);
105 //-----------------------------------------------------------------------------
106 class PARSER_GET_USER: public BASE_PARSER {
109 ~PARSER_GET_USER() {}
110 int ParseStart(void *data, const char *el, const char **attr);
111 int ParseEnd(void *data, const char *el);
116 //-----------------------------------------------------------------------------
117 class PARSER_GET_USERS: public BASE_PARSER {
120 int ParseStart(void *data, const char *el, const char **attr);
121 int ParseEnd(void *data, const char *el);
124 time_t lastUserUpdateTime;
125 bool lastUpdateFound;
127 //-----------------------------------------------------------------------------
128 class PARSER_GET_TARIFFS: public BASE_PARSER {
130 int ParseStart(void *data, const char *el, const char **attr);
131 int ParseEnd(void *data, const char *el);
134 //-----------------------------------------------------------------------------
135 class PARSER_ADD_TARIFF: public BASE_PARSER {
137 int ParseStart(void *data, const char *el, const char **attr);
138 int ParseEnd(void *data, const char *el);
143 //-----------------------------------------------------------------------------
144 class PARSER_DEL_TARIFF: public BASE_PARSER {
146 int ParseStart(void *data, const char *el, const char **attr);
147 int ParseEnd(void *data, const char *el);
152 //-----------------------------------------------------------------------------
153 class PARSER_CHG_TARIFF: public BASE_PARSER {
155 int ParseStart(void *data, const char *el, const char **attr);
156 int ParseEnd(void *data, const char *el);
159 int ParseSlashedIntParams(int paramsNum, const string & s, int * params);
160 int ParseSlashedDoubleParams(int paramsNum, const string & s, double * params);
161 int CheckTariffData();
166 //-----------------------------------------------------------------------------/
167 class PARSER_ADD_USER: public BASE_PARSER {
170 virtual ~PARSER_ADD_USER() {}
171 int ParseStart(void *data, const char *el, const char **attr);
172 int ParseEnd(void *data, const char *el);
179 //-----------------------------------------------------------------------------
180 class PARSER_CHG_USER: public BASE_PARSER {
184 int ParseStart(void *data, const char *el, const char **attr);
185 int ParseEnd(void *data, const char *el);
189 string EncChar2String(const char *);
193 RESETABLE<uint64_t> * upr;
194 RESETABLE<uint64_t> * downr;
200 bool cashMustBeAdded;
203 //-----------------------------------------------------------------------------
204 class PARSER_DEL_USER: public BASE_PARSER {
206 int ParseStart(void *data, const char *el, const char **attr);
207 int ParseEnd(void *data, const char *el);
214 //-----------------------------------------------------------------------------
215 class PARSER_CHECK_USER: public BASE_PARSER {
217 int ParseStart(void *data, const char *el, const char **attr);
218 int ParseEnd(void *data, const char *el);
223 //-----------------------------------------------------------------------------
224 class PARSER_SEND_MESSAGE: public BASE_PARSER {
226 int ParseStart(void *data, const char *el, const char **attr);
227 int ParseEnd(void *data, const char *el);
230 enum {res_ok, res_params_error, res_unknown};
231 vector<string> logins;
232 int ParseLogins(const char * logins);
237 //-----------------------------------------------------------------------------