-SETTINGS_IMPL::SETTINGS_IMPL(const SETTINGS_IMPL & rval)
- : strError(),
- modulesPath(rval.modulesPath),
- dirName(rval.dirName),
- confDir(rval.confDir),
- scriptsDir(rval.scriptsDir),
- rules(rval.rules),
- logFile(rval.logFile),
- pidFile(rval.pidFile),
- monitorDir(rval.monitorDir),
- monitoring(rval.monitoring),
- detailStatWritePeriod(rval.detailStatWritePeriod),
- statWritePeriod(rval.statWritePeriod),
- stgExecMsgKey(rval.stgExecMsgKey),
- executersNum(rval.executersNum),
- fullFee(rval.fullFee),
- dayFee(rval.dayFee),
- dayResetTraff(rval.dayResetTraff),
- spreadFee(rval.spreadFee),
- freeMbAllowInet(rval.freeMbAllowInet),
- dayFeeIsLastDay(rval.dayFeeIsLastDay),
- writeFreeMbTraffCost(rval.writeFreeMbTraffCost),
- showFeeInCash(rval.showFeeInCash),
- messageTimeout(rval.messageTimeout),
- modulesSettings(rval.modulesSettings),
- storeModuleSettings(rval.storeModuleSettings),
- logger(GetStgLogger())
-{
-}
-//-----------------------------------------------------------------------------
-int SETTINGS_IMPL::ParseYesNo(const string & value, bool * val)
-{
-if (0 == strcasecmp(value.c_str(), "yes"))
- {
- *val = true;
- return 0;
- }
-if (0 == strcasecmp(value.c_str(), "no"))
- {
- *val = false;
- return 0;
- }
-
-strError = "Incorrect value \'" + value + "\'.";
-return -1;
-}
-//-----------------------------------------------------------------------------
-int SETTINGS_IMPL::ParseInt(const string & value, int * val)
-{
-if (str2x<int>(value, *val))
- {
- strError = "Cannot convert \'" + value + "\' to integer.";
- return -1;
- }
-return 0;
-}
-//-----------------------------------------------------------------------------
-int SETTINGS_IMPL::ParseUnsigned(const string & value, unsigned * val)
-{
-if (str2x<unsigned>(value, *val))
- {
- strError = "Cannot convert \'" + value + "\' to unsigned integer.";
- return -1;
- }
-return 0;
-}
-//-----------------------------------------------------------------------------
-int SETTINGS_IMPL::ParseIntInRange(const string & value, int min, int max, int * val)
-{
-if (ParseInt(value, val) != 0)
- return -1;
-
-if (*val < min || *val > max)
- {
- strError = "Value \'" + value + "\' out of range.";
- return -1;
- }
-
-return 0;
-}
-//-----------------------------------------------------------------------------
-int SETTINGS_IMPL::ParseUnsignedInRange(const string & value, unsigned min, unsigned max, unsigned * val)
-{
-if (ParseUnsigned(value, val) != 0)
- return -1;
-
-if (*val < min || *val > max)
- {
- strError = "Value \'" + value + "\' out of range.";
- return -1;
- }
-
-return 0;
-}
-//-----------------------------------------------------------------------------
-int SETTINGS_IMPL::ParseModuleSettings(const DOTCONFDocumentNode * node, vector<PARAM_VALUE> * params)
-{
-const DOTCONFDocumentNode * childNode;
-PARAM_VALUE pv;
-const char * value;
-
-pv.param = node->getName();
-
-if (node->getValue(1))
- {
- strError = "Unexpected value \'" + string(node->getValue(1)) + "\'.";
- return -1;
- }
-
-value = node->getValue(0);
-
-if (!value)
- {
- strError = "Module name expected.";
- return -1;
- }
-
-childNode = node->getChildNode();
-while (childNode)
- {
- pv.param = childNode->getName();
- int i = 0;
- while ((value = childNode->getValue(i++)) != NULL)
- {
- pv.value.push_back(value);
- }
- params->push_back(pv);
- pv.value.clear();
- childNode = childNode->getNextNode();
- }
-
-return 0;
-}
-//-----------------------------------------------------------------------------