1 #ifndef DUNE_FEM_IO_PARAMETER_PARSER_HH 2 #define DUNE_FEM_IO_PARAMETER_PARSER_HH 8 #include <dune/common/fmatrix.hh> 22 static bool parse (
const std::string &s, T &value )
24 std::istringstream in( s );
26 if( std::is_same< T, std::string >::value && s.empty() )
37 std::ostringstream out;
46 static bool parse (
const std::string &s,
bool &value )
51 if( (w == std::string(
"false" )) || (w == std::string(
"no" )) || (w == std::string(
"0" )) )
57 if( (w == std::string(
"true" )) || (w == std::string(
"yes" )) || (w == std::string(
"1" )) )
66 static std::string
toString (
const bool &value )
68 return std::string( value ?
"true" :
"false" );
72 template<
class F,
int m,
int n >
75 static bool parse (
const std::string &s, FieldMatrix< F, m, n > &value )
77 std::istringstream in( s );
79 for(
int i = 0; i < m; ++i )
88 for(
int j = 0; j < n; ++j )
89 in >> value[ i ][ j ];
95 static std::string
toString (
const FieldMatrix< F, m, n > &value )
97 std::ostringstream out;
98 for(
int i = 0; i < m; ++i )
100 out << (i > 0 ?
"," :
"");
101 for(
int j = 0; j< n; ++j )
102 out <<
" " << value[ i ][ j ];
112 #endif // #ifndef DUNE_FEM_IO_PARAMETER_PARSER_HH
static bool parse(const std::string &s, FieldMatrix< F, m, n > &value)
Definition: parser.hh:75
static bool parse(const std::string &s, bool &value)
Definition: parser.hh:46
static bool parse(const std::string &s, T &value)
Definition: parser.hh:22
Definition: coordinate.hh:4
static std::string toString(const FieldMatrix< F, m, n > &value)
Definition: parser.hh:95
static std::string toString(const bool &value)
Definition: parser.hh:66
static std::string toString(const T &value)
Definition: parser.hh:35