bounds() wrapper for type labels
This commit is contained in:
@ -604,7 +604,7 @@ void utils::bounds(const char *file, int line, const std::string &str,
|
|||||||
{
|
{
|
||||||
nlo = nhi = -1;
|
nlo = nhi = -1;
|
||||||
|
|
||||||
// check for illegal charcters
|
// check for illegal characters
|
||||||
size_t found = str.find_first_not_of("*-0123456789");
|
size_t found = str.find_first_not_of("*-0123456789");
|
||||||
if (found != std::string::npos) {
|
if (found != std::string::npos) {
|
||||||
if (error) error->all(file, line, "Invalid range string: {}", str);
|
if (error) error->all(file, line, "Invalid range string: {}", str);
|
||||||
@ -647,6 +647,30 @@ template void utils::bounds<>(const char *, int, const std::string &,
|
|||||||
bigint, bigint, long &, long &, Error *);
|
bigint, bigint, long &, long &, Error *);
|
||||||
template void utils::bounds<>(const char *, int, const std::string &,
|
template void utils::bounds<>(const char *, int, const std::string &,
|
||||||
bigint, bigint, long long &, long long &, Error *);
|
bigint, bigint, long long &, long long &, Error *);
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
wrapper for bounds() that accepts type label input
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
template <typename TYPE>
|
||||||
|
void utils::bounds_typelabel(const char *file, int line, const std::string &str, bigint nmin,
|
||||||
|
bigint nmax, TYPE &nlo, TYPE &nhi, Error *error, LAMMPS *lmp, int mode)
|
||||||
|
{
|
||||||
|
nlo = nhi = -1;
|
||||||
|
char *typestr;
|
||||||
|
if ( typestr = utils::expand_type(FLERR, str, mode, lmp) )
|
||||||
|
nlo = nhi = utils::inumeric(FLERR, typestr, false, lmp);
|
||||||
|
delete[] typestr;
|
||||||
|
if (nlo > -1) return;
|
||||||
|
else utils::bounds(file, line, str, nmin, nmax, nlo, nhi, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
template void utils::bounds_typelabel<>(const char *, int, const std::string &,
|
||||||
|
bigint, bigint, int &, int &, Error *, LAMMPS *, int);
|
||||||
|
template void utils::bounds_typelabel<>(const char *, int, const std::string &,
|
||||||
|
bigint, bigint, long &, long &, Error *, LAMMPS *, int);
|
||||||
|
template void utils::bounds_typelabel<>(const char *, int, const std::string &,
|
||||||
|
bigint, bigint, long long &, long long &, Error *, LAMMPS *, int);
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------
|
/* -------------------------------------------------------------------------
|
||||||
|
|||||||
13
src/utils.h
13
src/utils.h
@ -331,6 +331,19 @@ namespace utils {
|
|||||||
void bounds(const char *file, int line, const std::string &str, bigint nmin, bigint nmax,
|
void bounds(const char *file, int line, const std::string &str, bigint nmin, bigint nmax,
|
||||||
TYPE &nlo, TYPE &nhi, Error *error);
|
TYPE &nlo, TYPE &nhi, Error *error);
|
||||||
|
|
||||||
|
/*! Same as bounds(), but supports type labels
|
||||||
|
*
|
||||||
|
* This functions adds the following case:
|
||||||
|
*
|
||||||
|
* - a single type label, typestr: nlo = nhi = label2type(typestr)
|
||||||
|
*
|
||||||
|
* \param lmp pointer to top-level LAMMPS class instance
|
||||||
|
* \param mode select labelmap using constants from Atom class */
|
||||||
|
|
||||||
|
template <typename TYPE>
|
||||||
|
void bounds_typelabel(const char *file, int line, const std::string &str, bigint nmin, bigint nmax,
|
||||||
|
TYPE &nlo, TYPE &nhi, Error *error, LAMMPS *lmp, int mode);
|
||||||
|
|
||||||
/*! Expand list of arguments when containing fix/compute wildcards
|
/*! Expand list of arguments when containing fix/compute wildcards
|
||||||
*
|
*
|
||||||
* This function searches the list of arguments in *arg* for strings
|
* This function searches the list of arguments in *arg* for strings
|
||||||
|
|||||||
Reference in New Issue
Block a user