ExaDG
Toggle main menu visibility
Loading...
Searching...
No Matches
include
exadg
utilities
enum_patterns.h
1
/* ______________________________________________________________________
2
*
3
* ExaDG - High-Order Discontinuous Galerkin for the Exa-Scale
4
*
5
* Copyright (C) 2022 by the ExaDG authors
6
*
7
* This program is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
10
* (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this program. If not, see <https://www.gnu.org/licenses/>.
19
* ______________________________________________________________________
20
*/
21
22
#ifndef EXADG_UTILITIES_ENUM_PATTERNS_H_
23
#define EXADG_UTILITIES_ENUM_PATTERNS_H_
24
25
// deal.II
26
#include <deal.II/base/patterns.h>
27
28
// ExaDG
29
#include <exadg/utilities/enum_utilities.h>
30
31
// C/C++
32
#include <string>
33
34
#ifdef DEAL_II_WITH_MAGIC_ENUM
35
namespace
ExaDG
36
{
37
namespace
Patterns
38
{
42
template
<
typename
T>
43
dealii::Patterns::List
44
Enum()
45
{
46
return
*dealii::Patterns::Tools::Convert<T>::to_pattern();
47
}
48
49
}
// namespace Patterns
50
}
// namespace ExaDG
51
#else
52
namespace
dealii
53
{
54
namespace
Patterns
55
{
56
namespace
Tools
57
{
70
template
<
typename
T>
71
struct
Convert<T, typename std::enable_if<ExaDG::Utilities::is_enum<T>()>::type>
72
{
76
static
std::unique_ptr<Patterns::Selection>
77
to_pattern
()
78
{
79
return
std::make_unique<Patterns::Selection>(
ExaDG::Utilities::serialized_string<T>
());
80
}
81
85
static
std::string
86
to_string
(T
const
& t, Patterns::PatternBase
const
& = *Convert<T>::to_pattern())
87
{
88
return
ExaDG::Utilities::enum_to_string
(t);
89
}
90
94
static
T
95
to_value
(
const
std::string & s, Patterns::PatternBase
const
& = *Convert<T>::to_pattern())
96
{
97
T value;
98
ExaDG::Utilities::string_to_enum
(value, s);
99
return
value;
100
}
101
};
102
103
}
// namespace Tools
104
}
// namespace Patterns
105
}
// namespace dealii
106
107
namespace
ExaDG
108
{
109
namespace
Patterns
110
{
114
template
<
typename
T>
115
dealii::Patterns::Selection
116
Enum()
117
{
118
return
*dealii::Patterns::Tools::Convert<T>::to_pattern();
119
}
120
121
}
// namespace Patterns
122
}
// namespace ExaDG
123
#endif
124
125
#endif
/*EXADG_UTILITIES_ENUM_PATTERNS_H_*/
ExaDG::Utilities::string_to_enum
void string_to_enum(EnumType &enum_type, std::string const &enum_name)
Converts a string to an enum, which is provided as first function argument.
Definition
enum_utilities.h:79
ExaDG::Utilities::serialized_string
std::string serialized_string()
Returns the names of the enums joined with "|".
Definition
enum_utilities.h:60
ExaDG::Utilities::enum_to_string
std::string enum_to_string(EnumType const enum_type)
Converts and enum to a string, returning the string.
Definition
enum_utilities.h:71
ExaDG
Definition
driver.cpp:33
dealii::Patterns::Tools::Convert< T, typename std::enable_if< ExaDG::Utilities::is_enum< T >()>::type >::to_pattern
static std::unique_ptr< Patterns::Selection > to_pattern()
Definition
enum_patterns.h:77
dealii::Patterns::Tools::Convert< T, typename std::enable_if< ExaDG::Utilities::is_enum< T >()>::type >::to_value
static T to_value(const std::string &s, Patterns::PatternBase const &= *Convert< T >::to_pattern())
Definition
enum_patterns.h:95
dealii::Patterns::Tools::Convert< T, typename std::enable_if< ExaDG::Utilities::is_enum< T >()>::type >::to_string
static std::string to_string(T const &t, Patterns::PatternBase const &= *Convert< T >::to_pattern())
Definition
enum_patterns.h:86
Generated by
1.17.0