X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/03f1c4e01b98531d28f040e47974750537b05c2f..d230cb2411b6d2d6603a930f165bbd3138831eeb:/projects/stargazer/plugins/configuration/sgconfig/parser_tariff.cpp
diff --git a/projects/stargazer/plugins/configuration/sgconfig/parser_tariff.cpp b/projects/stargazer/plugins/configuration/sgconfig/parser_tariff.cpp
index 9bac0294..88ab2670 100644
--- a/projects/stargazer/plugins/configuration/sgconfig/parser_tariff.cpp
+++ b/projects/stargazer/plugins/configuration/sgconfig/parser_tariff.cpp
@@ -29,125 +29,131 @@ return -1;
//-----------------------------------------------------------------------------
void PARSER_GET_TARIFFS::CreateAnswer()
{
-string s;
-char vs[100];
-int hd, hn, md, mn;
-
-answerList->erase(answerList->begin(), answerList->end());
-
-answerList->push_back("");
+answer = "";
std::list dataList;
tariffs->GetTariffsData(&dataList);
std::list::const_iterator it = dataList.begin();
for (; it != dataList.end(); ++it)
{
- s = "tariffConf.name + "\">";
- answerList->push_back(s);
+ answer += "tariffConf.name + "\">";
- for (int j = 0; j < DIR_NUM; j++)
- {
- hd = it->dirPrice[j].hDay;
- md = it->dirPrice[j].mDay;
-
- hn = it->dirPrice[j].hNight;
- mn = it->dirPrice[j].mNight;
-
- strprintf(&s, "");
+ answer += "tariffConf.period) + "\"/>";
+
+ answer += "";
}
-answerList->push_back("");
+answer += "";
}
//-----------------------------------------------------------------------------
// ADD TARIFF
@@ -177,19 +183,10 @@ return -1;
//-----------------------------------------------------------------------------
void PARSER_ADD_TARIFF::CreateAnswer()
{
-//answerList->clear();
-answerList->erase(answerList->begin(), answerList->end());
-
if (tariffs->Add(tariffToAdd, currAdmin) == 0)
- {
- answerList->push_back("");
- }
+ answer = "";
else
- {
- string s;
- strprintf(&s, "", tariffs->GetStrError().c_str());
- answerList->push_back(s);
- }
+ answer = "GetStrError() + "\"/>";
}
//-----------------------------------------------------------------------------
// DEL TARIFF
@@ -217,34 +214,19 @@ return -1;
//-----------------------------------------------------------------------------
void PARSER_DEL_TARIFF::CreateAnswer()
{
-//answerList->clear();
-answerList->erase(answerList->begin(), answerList->end());
-
if (users->TariffInUse(tariffToDel))
- {
- string s;
- strprintf(&s, "", tariffToDel.c_str());
- answerList->push_back(s);
- return;
- }
-
-if (tariffs->Del(tariffToDel, currAdmin) == 0)
- {
- answerList->push_back("");
- }
+ answer = "";
+else if (tariffs->Del(tariffToDel, currAdmin) == 0)
+ answer = "";
else
- {
- string s;
- strprintf(&s, "", tariffs->GetStrError().c_str());
- answerList->push_back(s);
- }
+ answer = "GetStrError() + "\"/>";
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// CHG TARIFF
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-int PARSER_CHG_TARIFF::ParseSlashedIntParams(int paramsNum, const string & s, int * params)
+int PARSER_CHG_TARIFF::ParseSlashedIntParams(int paramsNum, const std::string & s, int * params)
{
char * str = new char[s.size() + 1];
char * p;
@@ -272,7 +254,7 @@ delete[] str;
return 0;
}
//-----------------------------------------------------------------------------
-int PARSER_CHG_TARIFF::ParseSlashedDoubleParams(int paramsNum, const string & s, double * params)
+int PARSER_CHG_TARIFF::ParseSlashedDoubleParams(int paramsNum, const std::string & s, double * params)
{
char * str = new char[s.size() + 1];
char * p;
@@ -302,7 +284,6 @@ return 0;
//-----------------------------------------------------------------------------
int PARSER_CHG_TARIFF::ParseStart(void *, const char * el, const char ** attr)
{
-char st[50];
double price[DIR_NUM];
int t[DIR_NUM];
depth++;
@@ -317,7 +298,7 @@ if (depth == 1)
}
else
{
- string s;
+ std::string s;
if (strcasecmp(el, "PriceDayA") == 0)
{
@@ -385,6 +366,7 @@ else
for (int j = 0; j < DIR_NUM; j++)
{
+ char st[50];
snprintf(st, 50, "Time%d", j);
if (strcasecmp(el, st) == 0)
{
@@ -451,6 +433,12 @@ else
}
return 0;
}
+
+ if (strcasecmp(el, "Period") == 0)
+ {
+ td.tariffConf.period = TARIFF::StringToPeriod(attr[1]);
+ return 0;
+ }
}
return -1;
}
@@ -473,24 +461,20 @@ return -1;
//-----------------------------------------------------------------------------
void PARSER_CHG_TARIFF::CreateAnswer()
{
-answerList->erase(answerList->begin(), answerList->end());
-
if (!td.tariffConf.name.data().empty())
{
TARIFF_DATA tariffData = td.GetData();
if (tariffs->Chg(tariffData, currAdmin) == 0)
{
- answerList->push_back("");
+ answer = "";
return;
}
else
{
- string s;
- strprintf(&s, "", tariffs->GetStrError().c_str());
- answerList->push_back(s);
+ answer = "GetStrError() + "\"/>";
return;
}
}
-answerList->push_back("");
+answer = "";
}
//-----------------------------------------------------------------------------