| 132 | } |
| 133 | |
| 134 | bool ConfigurationParser::GetBool(const std::string& key, bool defaultValue) const |
| 135 | { |
| 136 | auto v = entries.find(key); |
| 137 | if (v == entries.end()) return defaultValue; |
| 138 | if (Equal(v->second, "true", StringComparison::IgnoureCase | StringComparison::IgnoreSurroudingWhiteSpaces)) |
| 139 | return true; |
| 140 | else if (Equal(v->second, "false", StringComparison::IgnoureCase | StringComparison::IgnoreSurroudingWhiteSpaces)) |
| 141 | return false; |
| 142 | try |
| 143 | { |
| 144 | return stod(v->second); |
| 145 | } catch (const exception&) |
| 146 | { |
| 147 | throw_with_nested(Exception("�������á�" + key + "��ֵת��Ϊbool��")); |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | ConfigurationParser::ConfigurationParser(istream& inputStream) : entries() |
| 152 | { |