add group::assign convenience version

This commit is contained in:
Jacob Gissinger
2020-06-26 21:36:12 -06:00
parent 77a6c7b7dc
commit 7f05c578f5
2 changed files with 17 additions and 0 deletions

View File

@ -547,6 +547,22 @@ void Group::assign(int narg, char **arg)
}
}
/* ----------------------------------------------------------------------
convenience function to allow assigning to groups from a single string
------------------------------------------------------------------------- */
void Group::assign(const std::string &fixcmd)
{
std::vector<std::string> args = utils::split_words(fixcmd);
char **newarg = new char*[args.size()];
int i=0;
for (const auto &arg : args) {
newarg[i++] = (char *)arg.c_str();
}
assign(args.size(),newarg);
delete[] newarg;
}
/* ----------------------------------------------------------------------
add flagged atoms to a new or existing group
------------------------------------------------------------------------- */