* Interpret settings value based on registered flags. * * @param[in] key key information to know if key was negated * @param[in] value string value of setting to be parsed * @param[in] flags ArgsManager registered argument flags * @param[out] error Error description if settings value is not valid * * @return parsed settings value if it is valid, otherwise nullopt accomp
| 241 | * by a descriptive error string |
| 242 | */ |
| 243 | static std::optional<util::SettingsValue> InterpretValue(const KeyInfo& key, const std::string& value, |
| 244 | unsigned int flags, std::string& error) |
| 245 | { |
| 246 | // Return negated settings as false values. |
| 247 | if (key.negated) { |
| 248 | if (flags & ArgsManager::DISALLOW_NEGATION) { |
| 249 | error = strprintf("Negating of -%s is meaningless and therefore forbidden", key.name); |
| 250 | return std::nullopt; |
| 251 | } |
| 252 | // Double negatives like -nofoo=0 are supported (but discouraged) |
| 253 | if (!InterpretBool(value)) { |
| 254 | LogPrintf("Warning: parsed potentially confusing double-negative -%s=%s\n", key.name, value); |
| 255 | return true; |
| 256 | } |
| 257 | return false; |
| 258 | } |
| 259 | return value; |
| 260 | } |
| 261 | |
| 262 | // Define default constructor and destructor that are not inline, so code instantiating this class doesn't need to |
| 263 | // #include class definitions for all members. |
no test coverage detected