Simplify count_words, add trim_and_count_words
The original count_words function (before it was put into utils::) also trimmed comments. For compatibility this behaviour was retained at first. However, due to the name the trimming is not immediatly apparent and many times not wanted. Therefore, this commit replaces count_words with an implementation that just does what it says. If a comment should be trimmed there is a trim_comment function. For convenience, a trim_and_count_words function was added and is now used where the old behaviour was needed.
This commit is contained in:
10
src/utils.h
10
src/utils.h
@ -142,13 +142,21 @@ namespace LAMMPS_NS {
|
||||
*/
|
||||
std::string trim_comment(const std::string & line);
|
||||
|
||||
/**
|
||||
* \brief Count words in string
|
||||
* \param text string that should be searched
|
||||
* \param seperators string containing characters that will be treated as whitespace
|
||||
* \return number of words found
|
||||
*/
|
||||
size_t count_words(const std::string & text, const std::string & seperators = " \t\r\n\f");
|
||||
|
||||
/**
|
||||
* \brief Count words in a single line, trim anything from '#' onward
|
||||
* \param text string that should be trimmed and searched
|
||||
* \param seperators string containing characters that will be treated as whitespace
|
||||
* \return number of words found
|
||||
*/
|
||||
size_t count_words(const std::string & text, const std::string & seperators = " \t\r\n\f");
|
||||
size_t trim_and_count_words(const std::string & text, const std::string & seperators = " \t\r\n\f");
|
||||
|
||||
/**
|
||||
* \brief Check if string can be converted to valid integer
|
||||
|
||||
Reference in New Issue
Block a user