.. _program_listing_file_components_Util_src_StringUtil.cpp: Program Listing for File StringUtil.cpp ======================================= |exhale_lsh| :ref:`Return to documentation for file ` (``components/Util/src/StringUtil.cpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #include "StringUtil.h" #include #include #include #include namespace util { std::vector split(std::string source, char delimiter) { // See also: https://stackoverflow.com/questions/5167625/splitting-a-c-stdstring-using-tokens-e-g std::vector strings; std::istringstream iss(source); std::string s; while (std::getline(iss, s, delimiter)) { strings.push_back(trim(s)); } return strings; } std::string toLower(std::string& value) { std::transform(value.begin(), value.end(), value.begin(), [](unsigned char c) -> unsigned char { return std::tolower(c); }); return value; } std::string trim(const std::string& str) { std::size_t first = str.find_first_not_of(' '); if (std::string::npos == first) return str; std::size_t last = str.find_last_not_of(' '); return str.substr(first, (last - first + 1)); } } // namespace util