You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be helpful to have functions to validate numeric and boolean configuration options passed as strings. Boolean parsing with CPLTestBool is interprets unexpected values to mean "false" (such as an enthusiastic "YESSS"). Similarly, atoi and atofare used for integer/floating point values but there may be cases where want to fail rather than overflow or accept a default value of zero.
Possible signature patterns:
std::optional<T> read(std::string_view)
bool read(const char*, T*)
int CPLGetIntegerConfigOption(const char* pszOptName, int nDefaultValue, bool* pbValid, bool* pbHasBeenUserSpecified = nullptr, int nMin = INT_MIN, int nMax = INT_MAX)
Feature description
It would be helpful to have functions to validate numeric and boolean configuration options passed as strings. Boolean parsing with
CPLTestBool
is interprets unexpected values to mean "false" (such as an enthusiastic "YESSS"). Similarly,atoi
andatof
are used for integer/floating point values but there may be cases where want to fail rather than overflow or accept a default value of zero.Possible signature patterns:
std::from_chars
is a nice way to do implement this but it does not support floating point types even in many recent compiler versions (https://en.cppreference.com/w/cpp/compiler_support/17#C.2B.2B17_library_features)Some previous discussion: #9924 (comment)
Additional context
No response
The text was updated successfully, but these errors were encountered: