8#include <deal.II/base/parameter_acceptor.h>
18struct ConversionHelper : std::false_type {
29struct Patterns::Tools::
30 Convert<T, typename std::enable_if_t<ConversionHelper<T>::value>> {
32 static std::unique_ptr<Patterns::PatternBase> to_pattern()
34 static const auto conversion_table = ConversionHelper<T>().conversion_table;
36 for (
const auto &it : conversion_table)
37 s = s.empty() ? std::get<1>(it) : s +
"|" + std::get<1>(it);
38 return std::make_unique<Patterns::Selection>(s);
43 const Patterns::PatternBase & = *Convert<T>::to_pattern())
45 static const auto conversion_table = ConversionHelper<T>().conversion_table;
46 for (
const auto &it : conversion_table) {
47 if (std::get<0>(it) == t)
48 return std::get<1>(it);
52 dealii::ExcMessage(
"Incomplete conversion table - unable to "
53 "identify matching string"));
57 to_value(
const std::string &s,
58 const Patterns::PatternBase &pattern = *Convert<T>::to_pattern())
60 AssertThrow(pattern.match(s), ExcNoMatch(s, pattern.description()));
62 static const auto conversion_table = ConversionHelper<T>().conversion_table;
63 for (
const auto &it : conversion_table) {
64 if (std::get<1>(it) == s)
65 return std::get<0>(it);
69 dealii::ExcMessage(
"Incomplete conversion table - unable to "
70 "identify matching value"));
74DEAL_II_NAMESPACE_CLOSE
76#define LIST(...) __VA_ARGS__
84#define DECLARE_ENUM(type, s) \
88 struct ConversionHelper<type> : std::true_type { \
89 const std::vector<std::tuple<type, std::string>> conversion_table = {s}; \
92 static_assert(true, "")