add star_subst() utility function that replaces a '*' in a string with a number

This commit is contained in:
Axel Kohlmeyer
2022-03-28 22:40:15 -04:00
parent d80fe166d1
commit 3ba7b8c24c
4 changed files with 50 additions and 2 deletions

View File

@ -368,13 +368,27 @@ namespace utils {
std::string trim(const std::string &line);
/*! Return string with anything from '#' onward removed
/*! Return string with anything from the first '#' character onward removed
*
* \param line string that should be trimmed
* \return new string without comment (string) */
std::string trim_comment(const std::string &line);
/*! Replace first '*' character in a string with a number, optionally zero-padded
*
* If there is no '*' character in the string, return the original string.
* If the number requires more characters than the value of the *pad*
* argument, do not add zeros; otherwise add as many zeroes as needed to
* the left to make the the number representation *pad* characters wide.
*
* \param name string with file containing a '*' (or not)
* \param step step number to replace the (first) '*'
* \param pad zero-padding (may be zero)
* \return processed string */
std::string star_subst(const std::string &name, bigint step, int pad);
/*! Check if a string will likely have UTF-8 encoded characters
*
* UTF-8 uses the 7-bit standard ASCII table for the first 127 characters and