diff options
| -rw-r--r-- | toolsrc/include/vcpkg_Strings.h | 2 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg_Strings.cpp | 10 |
2 files changed, 12 insertions, 0 deletions
diff --git a/toolsrc/include/vcpkg_Strings.h b/toolsrc/include/vcpkg_Strings.h index 92c24298c..a117a1a81 100644 --- a/toolsrc/include/vcpkg_Strings.h +++ b/toolsrc/include/vcpkg_Strings.h @@ -73,4 +73,6 @@ namespace vcpkg {namespace Strings void trim(std::string* s); std::string trimmed(const std::string& s); + + void trim_all_and_remove_whitespace_strings(std::vector<std::string>* strings); }} diff --git a/toolsrc/src/vcpkg_Strings.cpp b/toolsrc/src/vcpkg_Strings.cpp index 4859a480b..403900dae 100644 --- a/toolsrc/src/vcpkg_Strings.cpp +++ b/toolsrc/src/vcpkg_Strings.cpp @@ -9,6 +9,7 @@ namespace vcpkg {namespace Strings {namespace details { + // To disambiguate between two overloads static const auto isspace = [](const char c) { return std::isspace(c); @@ -105,4 +106,13 @@ namespace vcpkg {namespace Strings auto whitespace_back = std::find_if_not(s.rbegin(), s.rend(), details::isspace).base(); return (whitespace_back <= whitespace_front ? std::string() : std::string(whitespace_front, whitespace_back)); } + + void trim_all_and_remove_whitespace_strings(std::vector<std::string>* strings) + { + strings->erase(std::remove_if(strings->begin(), strings->end(), [](std::string& s)-> bool + { + trim(&s); + return s == ""; + }), strings->end()); + } }} |
