#include "stg/tariffs.h"
#include "stg/users.h"
-#include "stg/common.h"
#include "stg/resetable.h"
#include <cstdio> // snprintf
return res;
}
+template <typename T>
+bool str2res(const std::string& source, RESETABLE<T>& dest, T divisor)
+{
+ T value = 0;
+ if (str2x(source, value))
+ return false;
+ dest = value / divisor;
+ return true;
+}
+
template <typename A, typename C, typename F>
bool String2AOS(const std::string & source, A & array, size_t size, RESETABLE<F> C::* field, F divisor)
{
std::string::size_type pos = 0;
while (index < size && (pos = source.find('/', from)) != std::string::npos)
{
- if (str2x(source.substr(from, pos - from), (array[index].*field).data()))
+ if (!str2res(source.substr(from, pos - from), array[index].*field, divisor))
return false;
- (array[index].*field).data() /= divisor;
from = pos + 1;
++index;
}
- if (str2x(source.substr(from), (array[index].*field).data()))
+ if (str2res(source.substr(from), array[index].*field, divisor))
return false;
- (array[index].*field).data() /= divisor;
return true;
}
void GET_TARIFFS::CreateAnswer()
{
- m_answer = GetOpenTag();
+ m_answer = "<Tariffs>";
std::list<TARIFF_DATA> dataList;
m_tariffs.GetTariffsData(&dataList);
"</tariff>";
}
- m_answer += GetCloseTag();
+ m_answer += "</Tariffs>";
}
int ADD_TARIFF::Start(void *, const char * el, const char ** attr)