add utils::logical() function to complement the *numeric() functions

This commit is contained in:
Axel Kohlmeyer
2021-09-16 17:52:51 -04:00
parent 0dd35bdb66
commit cef100991f
5 changed files with 187 additions and 0 deletions

View File

@ -160,6 +160,19 @@ namespace utils {
std::string check_packages_for_style(const std::string &style, const std::string &name,
LAMMPS *lmp);
/*! Convert a string to a boolean while checking whether it is a valid boolean term.
* Valid terms are 'yes', 'no', 'true', 'false', 'on', 'off', '1', '0'. Capilatization
* will be ignored (thus 'yEs' or 'nO' are valid, 'yay' or 'nay' are not).
*
* \param file name of source file for error message
* \param line line number in source file for error message
* \param str string to be converted to logical
* \param do_abort determines whether to call Error::one() or Error::all()
* \param lmp pointer to top-level LAMMPS class instance
* \return boolean */
bool logical(const char *file, int line, const char *str, bool do_abort, LAMMPS *lmp);
/*! Convert a string to a floating point number while checking
* if it is a valid floating point or integer number
*