3 $Date: 2010/10/04 20:26:10 $
14 #include "resetable.h"
15 #include "stg_const.h"
20 #include "stg_message.h"
25 //-----------------------------------------------------------------------------
37 virtual ~BASE_PARSER() {}
38 virtual int ParseStart(void *data, const char *el, const char **attr) = 0;
39 virtual int ParseEnd(void *data, const char *el) = 0;
40 virtual void CreateAnswer() = 0;
41 virtual void SetAnswerList(std::list<std::string> * ansList) { answerList = ansList; }
43 virtual void SetUsers(USERS * u) { users = u; }
44 virtual void SetAdmins(ADMINS * a) { admins = a; }
45 virtual void SetTariffs(TARIFFS * t) { tariffs = t; }
46 virtual void SetStore(STORE * s) { store = s; }
47 virtual void SetStgSettings(const SETTINGS * s) { settings = s; }
49 virtual void SetCurrAdmin(ADMIN & cua) { currAdmin = &cua; }
50 virtual std::string & GetStrError() { return strError; }
51 virtual void Reset() { answerList->clear(); depth = 0; }
58 const SETTINGS * settings;
61 std::list<std::string> * answerList;
63 //-----------------------------------------------------------------------------
64 class PARSER_GET_ADMINS: public BASE_PARSER {
66 int ParseStart(void *data, const char *el, const char **attr);
67 int ParseEnd(void *data, const char *el);
70 //-----------------------------------------------------------------------------
71 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);
78 std::string adminToAdd;
80 //-----------------------------------------------------------------------------
81 class PARSER_DEL_ADMIN: public BASE_PARSER {
83 PARSER_DEL_ADMIN() : BASE_PARSER() {}
84 int ParseStart(void *data, const char *el, const char **attr);
85 int ParseEnd(void *data, const char *el);
88 int CheckAttr(const char **attr);
89 std::string adminToDel;
91 //-----------------------------------------------------------------------------
92 class PARSER_CHG_ADMIN: public BASE_PARSER {
94 PARSER_CHG_ADMIN() : BASE_PARSER() {}
95 int ParseStart(void *data, const char *el, const char **attr);
96 int ParseEnd(void *data, const char *el);
99 RESETABLE<std::string> login;
100 RESETABLE<std::string> password;
101 RESETABLE<std::string> privAsString;
103 //-----------------------------------------------------------------------------
104 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);
110 //-----------------------------------------------------------------------------
111 class PARSER_GET_USER: public BASE_PARSER {
114 ~PARSER_GET_USER(){};
115 int ParseStart(void *data, const char *el, const char **attr);
116 int ParseEnd(void *data, const char *el);
121 //-----------------------------------------------------------------------------
122 class PARSER_GET_USERS: public BASE_PARSER {
125 int ParseStart(void *data, const char *el, const char **attr);
126 int ParseEnd(void *data, const char *el);
129 time_t lastUserUpdateTime;
130 bool lastUpdateFound;
132 //-----------------------------------------------------------------------------
133 class PARSER_GET_TARIFFS: public BASE_PARSER {
135 int ParseStart(void *data, const char *el, const char **attr);
136 int ParseEnd(void *data, const char *el);
139 //-----------------------------------------------------------------------------
140 class PARSER_ADD_TARIFF: public BASE_PARSER {
142 PARSER_ADD_TARIFF() : BASE_PARSER() {}
143 int ParseStart(void *data, const char *el, const char **attr);
144 int ParseEnd(void *data, const char *el);
147 std::string tariffToAdd;
149 //-----------------------------------------------------------------------------
150 class PARSER_DEL_TARIFF: public BASE_PARSER {
152 PARSER_DEL_TARIFF() : BASE_PARSER() {}
153 int ParseStart(void *data, const char *el, const char **attr);
154 int ParseEnd(void *data, const char *el);
157 std::string tariffToDel;
159 //-----------------------------------------------------------------------------
160 class PARSER_CHG_TARIFF: public BASE_PARSER {
162 PARSER_CHG_TARIFF() : BASE_PARSER() {}
163 int ParseStart(void *data, const char *el, const char **attr);
164 int ParseEnd(void *data, const char *el);
167 int ParseSlashedIntParams(int paramsNum, const std::string & s, int * params);
168 int ParseSlashedDoubleParams(int paramsNum, const std::string & s, double * params);
169 int CheckTariffData();
174 //-----------------------------------------------------------------------------/
175 class PARSER_ADD_USER: public BASE_PARSER {
178 ~PARSER_ADD_USER() {}
179 int ParseStart(void *data, const char *el, const char **attr);
180 int ParseEnd(void *data, const char *el);
187 //-----------------------------------------------------------------------------
188 class PARSER_CHG_USER: public BASE_PARSER {
192 int ParseStart(void *data, const char *el, const char **attr);
193 int ParseEnd(void *data, const char *el);
197 std::string EncChar2String(const char *);
202 RESETABLE<uint64_t> * upr;
203 RESETABLE<uint64_t> * downr;
206 bool cashMustBeAdded;
209 //-----------------------------------------------------------------------------
210 class PARSER_DEL_USER: public BASE_PARSER {
212 PARSER_DEL_USER() : BASE_PARSER(), res(0) {}
213 int ParseStart(void *data, const char *el, const char **attr);
214 int ParseEnd(void *data, const char *el);
221 //-----------------------------------------------------------------------------
222 class PARSER_CHECK_USER: public BASE_PARSER {
224 PARSER_CHECK_USER() : BASE_PARSER(), result(false) {}
225 int ParseStart(void *data, const char *el, const char **attr);
226 int ParseEnd(void *data, const char *el);
231 //-----------------------------------------------------------------------------
232 class PARSER_SEND_MESSAGE: public BASE_PARSER {
234 PARSER_SEND_MESSAGE() : BASE_PARSER(), result(0) {}
235 int ParseStart(void *data, const char *el, const char **attr);
236 int ParseEnd(void *data, const char *el);
239 int ParseLogins(const char * logins);
241 enum {res_ok, res_params_error, res_unknown};
242 std::vector<std::string> logins;
247 //-----------------------------------------------------------------------------