3 $Date: 2010/10/04 20:26:10 $
14 #include "stg/resetable.h"
15 #include "stg/const.h"
16 #include "stg/store.h"
17 #include "stg/admins.h"
18 #include "stg/admin.h"
19 #include "stg/users.h"
20 #include "stg/message.h"
25 //-----------------------------------------------------------------------------
38 virtual ~BASE_PARSER() {}
39 virtual int ParseStart(void *data, const char *el, const char **attr) = 0;
40 virtual int ParseEnd(void *data, const char *el) = 0;
41 virtual void CreateAnswer() = 0;
42 virtual void SetAnswerList(std::list<std::string> * ansList) { answerList = ansList; }
44 virtual void SetUsers(USERS * u) { users = u; }
45 virtual void SetAdmins(ADMINS * a) { admins = a; }
46 virtual void SetTariffs(TARIFFS * t) { tariffs = t; }
47 virtual void SetStore(STORE * s) { store = s; }
48 virtual void SetStgSettings(const SETTINGS * s) { settings = s; }
50 virtual void SetCurrAdmin(ADMIN & cua) { currAdmin = &cua; }
51 virtual std::string & GetStrError() { return strError; }
52 virtual void Reset() { answerList->clear(); depth = 0; }
59 const SETTINGS * settings;
62 std::list<std::string> * answerList;
64 //-----------------------------------------------------------------------------
65 class PARSER_GET_ADMINS: public BASE_PARSER {
67 int ParseStart(void *data, const char *el, const char **attr);
68 int ParseEnd(void *data, const char *el);
71 //-----------------------------------------------------------------------------
72 class PARSER_ADD_ADMIN: public BASE_PARSER {
74 PARSER_ADD_ADMIN() : BASE_PARSER() {}
75 int ParseStart(void *data, const char *el, const char **attr);
76 int ParseEnd(void *data, const char *el);
79 std::string adminToAdd;
81 //-----------------------------------------------------------------------------
82 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);
90 std::string adminToDel;
92 //-----------------------------------------------------------------------------
93 class PARSER_CHG_ADMIN: public BASE_PARSER {
95 PARSER_CHG_ADMIN() : BASE_PARSER() {}
96 int ParseStart(void *data, const char *el, const char **attr);
97 int ParseEnd(void *data, const char *el);
100 RESETABLE<std::string> login;
101 RESETABLE<std::string> password;
102 RESETABLE<std::string> privAsString;
104 //-----------------------------------------------------------------------------
105 class PARSER_GET_SERVER_INFO: public BASE_PARSER {
107 int ParseStart(void *data, const char *el, const char **attr);
108 int ParseEnd(void *data, const char *el);
111 //-----------------------------------------------------------------------------
112 class PARSER_GET_USER: public BASE_PARSER {
115 ~PARSER_GET_USER(){};
116 int ParseStart(void *data, const char *el, const char **attr);
117 int ParseEnd(void *data, const char *el);
122 //-----------------------------------------------------------------------------
123 class PARSER_GET_USERS: public BASE_PARSER {
126 int ParseStart(void *data, const char *el, const char **attr);
127 int ParseEnd(void *data, const char *el);
130 time_t lastUserUpdateTime;
131 bool lastUpdateFound;
133 //-----------------------------------------------------------------------------
134 class PARSER_GET_TARIFFS: public BASE_PARSER {
136 int ParseStart(void *data, const char *el, const char **attr);
137 int ParseEnd(void *data, const char *el);
140 //-----------------------------------------------------------------------------
141 class PARSER_ADD_TARIFF: public BASE_PARSER {
143 PARSER_ADD_TARIFF() : BASE_PARSER() {}
144 int ParseStart(void *data, const char *el, const char **attr);
145 int ParseEnd(void *data, const char *el);
148 std::string tariffToAdd;
150 //-----------------------------------------------------------------------------
151 class PARSER_DEL_TARIFF: public BASE_PARSER {
153 PARSER_DEL_TARIFF() : BASE_PARSER() {}
154 int ParseStart(void *data, const char *el, const char **attr);
155 int ParseEnd(void *data, const char *el);
158 std::string tariffToDel;
160 //-----------------------------------------------------------------------------
161 class PARSER_CHG_TARIFF: public BASE_PARSER {
163 PARSER_CHG_TARIFF() : BASE_PARSER() {}
164 int ParseStart(void *data, const char *el, const char **attr);
165 int ParseEnd(void *data, const char *el);
168 int ParseSlashedIntParams(int paramsNum, const std::string & s, int * params);
169 int ParseSlashedDoubleParams(int paramsNum, const std::string & s, double * params);
170 int CheckTariffData();
175 //-----------------------------------------------------------------------------/
176 class PARSER_ADD_USER: public BASE_PARSER {
179 ~PARSER_ADD_USER() {}
180 int ParseStart(void *data, const char *el, const char **attr);
181 int ParseEnd(void *data, const char *el);
188 //-----------------------------------------------------------------------------
189 class PARSER_CHG_USER: public BASE_PARSER {
193 int ParseStart(void *data, const char *el, const char **attr);
194 int ParseEnd(void *data, const char *el);
198 std::string EncChar2String(const char *);
203 RESETABLE<uint64_t> * upr;
204 RESETABLE<uint64_t> * downr;
207 bool cashMustBeAdded;
210 //-----------------------------------------------------------------------------
211 class PARSER_DEL_USER: public BASE_PARSER {
213 PARSER_DEL_USER() : BASE_PARSER(), res(0), u(NULL) {}
214 int ParseStart(void *data, const char *el, const char **attr);
215 int ParseEnd(void *data, const char *el);
222 //-----------------------------------------------------------------------------
223 class PARSER_CHECK_USER: public BASE_PARSER {
225 PARSER_CHECK_USER() : BASE_PARSER(), result(false) {}
226 int ParseStart(void *data, const char *el, const char **attr);
227 int ParseEnd(void *data, const char *el);
232 //-----------------------------------------------------------------------------
233 class PARSER_SEND_MESSAGE: public BASE_PARSER {
235 PARSER_SEND_MESSAGE() : BASE_PARSER(), result(0), u(NULL) {}
236 int ParseStart(void *data, const char *el, const char **attr);
237 int ParseEnd(void *data, const char *el);
240 int ParseLogins(const char * logins);
242 enum {res_ok, res_params_error, res_unknown};
243 std::vector<std::string> logins;
248 //-----------------------------------------------------------------------------