<< "The string " << arg1 << " does not match the pattern \""
<< arg2.description() << "\"");
//@}
+}
+
+
+// ---------------------- inline and template functions --------------------
+namespace PatternsTools {
namespace internal
{
/**
static constexpr int map_rank = 0;
};
}
-}
-
-// ---------------------- inline and template functions --------------------
-namespace PatternsTools
-{
+ // Arithmetic types
template<class T>
struct Convert<T, typename std::enable_if<std::is_arithmetic<T>::value>::type>
{
static constexpr bool const value = internal::is_stl_map<std::decay_t<T>>::value;
};
+
namespace internal
{
// Rank of vector types
}
+ // stl containers
template<class T>
struct Convert<T, typename std::enable_if<is_stl_container<T>::value>::type>
{
};
+ // stl maps
template <class T>
struct Convert<T, typename std::enable_if<is_stl_map<T>::value>::type>
{
};
+ // Tensors
template<int rank, int dim, class Number>
struct Convert<Tensor<rank,dim,Number>>
{
};
+ // Points
template<int dim, class Number>
struct Convert<Point<dim,Number>>
{
};
-
+ // Complex numbers
template<class Number>
struct Convert<std::complex<Number>>
{
};
+ // Strings
+ template<>
+ struct Convert<std::string>
+ {
+ typedef std::string T;
+
+ static std::unique_ptr<PatternBase> to_pattern()
+ {
+ return std_cxx14::make_unique<Anything>();
+ }
+
+ static std::string to_string(const T &t,
+ const std::unique_ptr<PatternBase> &pattern = Convert<T>::to_pattern())
+ {
+ AssertThrow(pattern->match(t), ExcNoMatch(t,*pattern));
+ return t;
+ }
+
+ static T to_value(const std::string &s,
+ const std::unique_ptr<PatternBase> &pattern = Convert<T>::to_pattern())
+ {
+ AssertThrow(pattern->match(s), ExcNoMatch(s,*pattern));
+ return s;
+ }
+ };
+
template <class ParameterType>
void add_parameter(const std::string &entry,