1#ifndef DUNE_FEM_IO_PARAMETER_PARSER_HH
2#define DUNE_FEM_IO_PARAMETER_PARSER_HH
20 struct ParameterParser
22 static bool parse (
const std::string &s, T &value )
24 if constexpr ( std::is_same< T, std::string >::value )
32 std::istringstream in( s );
43 static std::string
toString (
const T &value )
45 std::ostringstream out;
52 struct ParameterParser< bool >
54 static bool parse (
const std::string &s,
bool &value )
57 if( ParameterParser< std::string >::parse( s, w ) )
59 std::transform(w.begin(), w.end(), w.begin(), ::tolower);
60 if( (w == std::string(
"false" )) || (w == std::string(
"no" )) || (w == std::string(
"0" )) )
66 if( (w == std::string(
"true" )) || (w == std::string(
"yes" )) || (w == std::string(
"1" )) )
75 static std::string
toString (
const bool &value )
77 return std::string( value ?
"true" :
"false" );
81 template<
class F,
int m,
int n >
82 struct ParameterParser< FieldMatrix< F, m, n > >
84 static bool parse (
const std::string &s, FieldMatrix< F, m, n > &value )
86 std::istringstream in( s );
88 for(
int i = 0; i < m; ++i )
97 for(
int j = 0; j < n; ++j )
98 in >> value[ i ][ j ];
104 static std::string
toString (
const FieldMatrix< F, m, n > &value )
106 std::ostringstream out;
107 for(
int i = 0; i < m; ++i )
109 out << (i > 0 ?
"," :
"");
110 for(
int j = 0; j< n; ++j )
111 out <<
" " << value[ i ][ j ];
std::string toString(Precision p)
map precision to VTK type name
Definition: common.hh:280
Implements a matrix constructed from a given type representing a field and compile-time given number ...
Dune namespace.
Definition: alignedallocator.hh:13