29 #ifndef NVXIO_OPTIONHANDLER_HPP
30 #define NVXIO_OPTIONHANDLER_HPP
55 typedef std::initializer_list<std::pair<std::string, T>> type;
59 typedef std::unique_ptr<OptionHandler>
ptr;
86 virtual std::string
processValue(
const std::string &valueStr)
const = 0;
148 static ptr oneOf(std::string *result, std::initializer_list<std::string> allowedValues);
167 template <
typename T>
168 static ptr oneOf(T *result,
typename PairList<T>::type allowedValues);
173 #include "detail/OptionHandler.hpp"
175 #endif // NVXIO_OPTIONHANDLER_HPP
The Range interface and utility functions.
virtual std::string processValue(const std::string &valueStr) const =0
Processes the value of the option.
static ptr unsignedInteger(unsigned *result, const Range< unsigned > &validRange=ranges::all< unsigned >())
Creates an option handler that accepts argument values that look like unsigned decimal integers...
static ptr string(std::string *result)
Creates an option handler that accepts any argument value and copies it verbatim to the provided vari...
std::unique_ptr< OptionHandler > ptr
virtual std::string getPlaceholder() const =0
Gets a short hint that describes the expected values of the option (i.e., a placeholder for the optio...
virtual std::string getDefaultString() const =0
Gets the default value of the option.
static ptr oneOf(std::string *result, std::initializer_list< std::string > allowedValues)
Creates an option handler that accepts argument values from a certain set and stores them in the prov...
static ptr real(float *result, const Range< float > &validRange=ranges::all< float >())
Creates an option handler that accepts argument values that look like real numbers, converts them to float, and then stores them in the provided variable.
virtual std::string getConstraintString() const
Gets information about valid values of the option.
static ptr integer(int *result, const Range< int > &validRange=ranges::all< int >())
Creates an option handler that accepts argument values that look like decimal integers, converts them to int, and then stores them in the provided variable.