const std::string &documentation = std::string());
/**
- * Enter a subsection; if not yet existent, declare it.
+ * Enter a subsection. If it does not yet exist, create it.
*/
void enter_subsection (const std::string &subsection);
DeclException1 (ExcEntryUndeclared,
std::string,
<< "You can't ask for entry <" << arg1 << "> you have not yet declared");
- /**
- * Exception
- */
- DeclException1 (ExcConversionError,
- std::string,
- << "Error when trying to convert the following string: " << arg1);
//@}
private:
/**
long int ParameterHandler::get_integer (const std::string &entry_string) const
{
- std::string s = get (entry_string);
- char *endptr;
- const long int i = std::strtol (s.c_str(), &endptr, 10);
-
- // assert that there was no error. an error would be if
- // either there was no string to begin with, or if
- // strtol set the endptr to anything but the end of
- // the string
- AssertThrow ((s.size()>0) && (*endptr == '\0'),
- ExcConversionError(s));
-
- return i;
+ try
+ {
+ return Utilities::string_to_int (get (entry_string));
+ }
+ catch (...)
+ {
+ AssertThrow (false,
+ ExcMessage("Can't convert the parameter value <"
+ + get(entry_string) +
+ "> for entry <"
+ + entry_string +
+ " to an integer."));
+ return 0;
+ }
}
double ParameterHandler::get_double (const std::string &entry_string) const
{
- std::string s = get (entry_string);
- char *endptr;
- double d = std::strtod (s.c_str(), &endptr);
-
- // assert that there was no error. an error would be if
- // either there was no string to begin with, or if
- // strtol set the endptr to anything but the end of
- // the string
- AssertThrow ((s.size()>0) && (*endptr == '\0'),
- ExcConversionError(s));
-
- return d;
+ try
+ {
+ return Utilities::string_to_double (get (entry_string));
+ }
+ catch (...)
+ {
+ AssertThrow (false,
+ ExcMessage("Can't convert the parameter value <"
+ + get(entry_string) +
+ "> for entry <"
+ + entry_string +
+ " to a double precision variable."));
+ return 0;
+ }
}
bool ParameterHandler::get_bool (const std::string &entry_string) const
{
- std::string s = get(entry_string);
+ const std::string s = get(entry_string);
AssertThrow ((s=="true") || (s=="false") ||
(s=="yes") || (s=="no"),
- ExcConversionError(s));
+ ExcMessage("Can't convert the parameter value <"
+ + get(entry_string) +
+ "> for entry <"
+ + entry_string +
+ " to a boolean."));
if (s=="true" || s=="yes")
return true;
else
// ---------------------------------------------------------------------
//
-// Copyright (C) 2002 - 2014 by the deal.II authors
+// Copyright (C) 2002 - 2015 by the deal.II authors
//
// This file is part of the deal.II library.
//
{
prm.get_double ("a");
}
- catch (const ParameterHandler::ExcConversionError &)
+ catch (...)
{
deallog << "get_double() detected the mistake" << std::endl;
}
{
prm.get_integer ("a");
}
- catch (const ParameterHandler::ExcConversionError &)
+ catch (...)
{
deallog << "get_integer() detected the mistake" << std::endl;
}
{
prm.get_bool ("a");
}
- catch (const ParameterHandler::ExcConversionError &)
+ catch (...)
{
deallog << "get_bool() detected the mistake" << std::endl;
}