bool ToBool(const wstring& str) { if (str.empty()) return false; const wchar_t c = str.front(); return (c == '1' || c == 't' || c == 'T' || c == 'y' || c == 'Y'); }
bool JstrChecker::IS_STRING(const wstring &str, wstring &strvl) { if (str.front() != JsonSymbol::STRING_BOUND || str.back() != JsonSymbol::STRING_BOUND) return false; strvl = L""; for (size_t i = 1; i < str.size() - 1; i++) { if (str[i] == JsonSymbol::ESCAPE_SYM) { if (i == str.size() - 2) return false; strvl.push_back(ESCAPE(str[i + 1])); i++; } else if (str[i] == JsonSymbol::STRING_BOUND) { return false; } else { strvl.push_back(str[i]); } } return true; }
void Service::SetFDDistributionPolicy(wstring const& distPolicy) { if (distPolicy.front() == L'P' || distPolicy.front() == L'p') { this->FDDistribution_ = Type::Packing; } else if (distPolicy.front() == L'N' || distPolicy.front() == L'n') { this->FDDistribution_ = Type::Nonpacking; } else if (distPolicy.front() == L'I' || distPolicy.front() == L'i') { this->FDDistribution_ = Type::Ignore; } else { //todo trace for invalid policy input } }