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 std::transform(w.begin(), w.end(), w.begin(), ::tolower);
52 if( (w == std::string(
"false" )) || (w == std::string(
"no" )) || (w == std::string(
"0" )) )
58 if( (w == std::string(
"true" )) || (w == std::string(
"yes" )) || (w == std::string(
"1" )) )
67 static std::string
toString (
const bool &value )
69 return std::string( value ?
"true" :
"false" );
73 template<
class F,
int m,
int n >
76 static bool parse (
const std::string &s, FieldMatrix< F, m, n > &value )
78 std::istringstream
in( s );
80 for(
int i = 0; i < m; ++i )
89 for(
int j = 0; j < n; ++j )
90 in >> value[ i ][ j ];
96 static std::string
toString (
const FieldMatrix< F, m, n > &value )
98 std::ostringstream
out;
99 for(
int i = 0; i < m; ++i )
101 out << (i > 0 ?
"," :
"");
102 for(
int j = 0; j< n; ++j )
103 out <<
" " << value[ i ][ j ];
Definition: bindguard.hh:11
static bool parse(const std::string &s, T &value)
Definition: parser.hh:22
static std::string toString(const T &value)
Definition: parser.hh:35
static bool parse(const std::string &s, bool &value)
Definition: parser.hh:46
static std::string toString(const bool &value)
Definition: parser.hh:67
static std::string toString(const FieldMatrix< F, m, n > &value)
Definition: parser.hh:96
static bool parse(const std::string &s, FieldMatrix< F, m, n > &value)
Definition: parser.hh:76