18#ifndef elxConversion_h
19#define elxConversion_h
57 static constexpr const char *
60 return arg ?
"true" :
"false";
91 template <
typename TInteger>
95 static_assert(std::is_integral_v<TInteger>,
"An integer type expected!");
96 static_assert(!std::is_same_v<TInteger, bool>,
"No bool expected!");
97 return std::to_string(integerValue);
109 template <
typename TContainer,
typename SFINAE =
typename TContainer::iterator>
110 static std::vector<std::string>
113 std::vector<std::string> result;
115 result.reserve(container.size());
117 for (
const auto element : container)
127 template <
typename T,
unsigned int NRows,
unsigned int NColumns>
128 static std::vector<std::string>
131 std::vector<std::string> result;
132 result.reserve(NColumns * NRows);
134 for (
unsigned column{}; column < NColumns; ++column)
136 for (
unsigned row{}; row < NRows; ++row)
146 template <
typename TValue>
147 static std::vector<TValue>
150 vector1.insert(end(vector1), std::make_move_iterator(begin(vector2)), std::make_move_iterator(end(vector2)));
177 static_assert(!std::is_same_v<T, bool>,
"This StringToValue<T> overload does not support bool!");
181 static_assert(
sizeof(T) > 1,
"This StringToValue<T> overload does not support (signed/unsigned) char!");
183 if (std::is_unsigned_v<T> && (!str.empty()) && (str.front() ==
'-'))
189 auto inputStream = [&str] {
190 const auto decimalPointPos = str.find_first_of(
'.');
191 const bool hasDecimalPointAndTrailingZeros =
192 (decimalPointPos != std::string::npos) &&
193 (
static_cast<std::uintmax_t
>(std::count(str.cbegin() + decimalPointPos + 1, str.cend(),
'0')) ==
194 (str.size() - decimalPointPos - 1));
195 return std::istringstream(
196 hasDecimalPointAndTrailingZeros ? std::string(str.cbegin(), str.cbegin() + decimalPointPos) : str);
200 return (inputStream >> value) && inputStream.eof();
A class that contains utility functions for the conversion of number of seconds and parameter values ...
static std::string ToString(float)
static std::vector< TValue > ConcatenateVectors(std::vector< TValue > vector1, std::vector< TValue > vector2)
std::map< std::string, ParameterValuesType > ParameterMapType
static std::vector< std::string > ToVectorOfStrings(const TContainer &container)
static std::vector< std::string > ToVectorOfStrings(const itk::Matrix< T, NRows, NColumns > &matrix)
static bool StringToValue(const std::string &str, T &value)
static std::string ToString(double)
static std::string SecondsToDHMS(const double totalSeconds, const unsigned int precision)
static bool StringToValue(const std::string &str, std::string &value)
static std::string ObjectPtrToString(itk::Object *)
std::vector< std::string > ParameterValuesType
static bool StringToValue(const std::string &str, itk::Object *&value)
static bool StringToValue(const std::string &str, bool &value)
static std::string ToString(const bool arg)
static bool StringToValue(const std::string &str, float &value)
static bool StringToValue(const std::string &str, char &value)
static bool IsNumber(const std::string &)
static itk::OptimizerParameters< double > ToOptimizerParameters(const std::vector< double > &)
static std::string ToString(const TInteger integerValue)
static std::string ParameterMapToString(const ParameterMapType &)
static bool StringToValue(const std::string &str, unsigned char &value)
static bool StringToValue(const std::string &str, double &value)
static std::string ToNativePathNameSeparators(const std::string &)
static bool StringToValue(const std::string &str, signed char &value)
static constexpr const char * BoolToString(const bool arg)
class ITK_TEMPLATE_EXPORT OptimizerParameters