[Dune] [Dune-Commit] dune-common r6009 - trunk/dune/common

Oliver Sander sander at mi.fu-berlin.de
Tue May 25 13:41:24 CEST 2010


Thanks!

Am 25.05.2010 13:39, schrieb joe at dune-project.org:
> Author: joe
> Date: 2010-05-25 13:39:28 +0200 (Tue, 25 May 2010)
> New Revision: 6009
>
> Modified:
>     trunk/dune/common/configparser.hh
> Log:
> [ConfigParser] Implement the non-specialized version of the
> ConfigParser::Parser helper template.
>
> This makes configparsertest compile.
>
> Modified: trunk/dune/common/configparser.hh
> ===================================================================
> --- trunk/dune/common/configparser.hh	2010-05-25 10:08:07 UTC (rev 6008)
> +++ trunk/dune/common/configparser.hh	2010-05-25 11:39:28 UTC (rev 6009)
> @@ -328,6 +328,25 @@
>   			static std::string rtrim(const std::string&  s);
>   	};
>
> +    template<typename T>
> +    struct ConfigParser::Parser {
> +        static T parse(const std::string&  str) {
> +            T val;
> +            std::istringstream s(str);
> +            s>>  val;
> +            if(!s)
> +                DUNE_THROW(RangeError, "Cannot parse value \""<<  str<<  "\""
> +                           "as a "<<  typeid(T).name());
> +            T dummy;
> +            s>>  dummy;
> +            // now extraction should have failed, and eof should be set
> +            if(not s.fail() or not s.eof())
> +                DUNE_THROW(RangeError, "Cannot parse value \""<<  str<<  "\""
> +                           "as a "<<  typeid(T).name());
> +            return val;
> +        }
> +    };
> +
>       template<typename T, int n>
>       struct ConfigParser::Parser<FieldVector<T, n>  >  {
>           static FieldVector<T, n>
>
>
> _______________________________________________
> Dune-Commit mailing list
> Dune-Commit at dune-project.org
> http://lists.dune-project.org/mailman/listinfo/dune-commit
>    


-- 
************************************************************************
* Oliver Sander                ** email: sander at mi.fu-berlin.de        *
* Freie Universität Berlin     ** phone: + 49 (30) 838 75348           *
* Institut für Mathematik      ** URL  : page.mi.fu-berlin.de/~sander  *
* Arnimallee 6                 ** -------------------------------------*
* 14195 Berlin, Germany        ** Member of MATHEON (www.matheon.de)   *
************************************************************************





More information about the Dune mailing list