Add functions for parsing and validating configuration options
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 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)
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: https://github.com/OSGeo/gdal/pull/9924#discussion_r1600656416
Additional context
No response
cf CPLGetValueType() : https://gdal.org/api/cpl.html#_CPPv415CPLGetValueTypePKc
I see that from_chars is also available from the vendored fast_float.