3#include <boost/algorithm/string.hpp>
14template<
typename TargetType>
16 std::istringstream stream(valueAsString);
18 conversionSuccessful = (stream >> t) && (stream >> std::ws).eof();
24 conversionSuccessful =
true;
30 static const std::string lowerTrueString =
"true";
31 static const std::string lowerFalseString =
"false";
32 static const std::string lowerYesString =
"yes";
33 static const std::string lowerNoString =
"no";
35 std::string lowerInput = boost::algorithm::to_lower_copy(s);
37 if (lowerInput.compare(lowerTrueString) == 0 || lowerInput.compare(lowerYesString) == 0) {
40 }
else if (lowerInput.compare(lowerFalseString) == 0 || lowerInput.compare(lowerNoString) == 0) {
45 std::istringstream stream(s);
47 ok = (stream >> t) && (stream >> std::ws).eof();
51template<
typename ValueType>
53 std::ostringstream stream;
static TargetType convertFromString(std::string const &valueAsString, bool &conversionSuccessful)
Converts the given value represented as a string to the type of the template parameter.
static std::string convertToString(ValueType const &value)
Converts the given value to a string representation.
virtual void printToStream(std::ostream &out) const =0
Prints a string representation of the argument to the provided stream.
ArgumentBase(std::string const &name, std::string const &description)
Constructs a new argument base with the given name, description and indication whether the argument i...
std::ostream & operator<<(std::ostream &out, ArgumentBase const &argument)
The contract of a DD backend.