#ifndef UTILITY_STRING_H #define UTILITY_STRING_H #include #include namespace utility { template ContainerType split(const std::string& str, char delimiter); template ContainerType split(const std::string& str, const std::string& delimiter); std::string substrAfter(const std::string& str, char delimiter); bool isPrefix(const std::string& prefix, const std::string& text); } template ContainerType utility::split(const std::string& str, char delimiter) { return split(str, std::string(1, delimiter)); } template ContainerType utility::split(const std::string& str, const std::string& delimiter) { size_t pos = 0; size_t oldPos = 0; ContainerType c; do { pos = str.find(delimiter, oldPos); c.push_back(str.substr(oldPos, pos - oldPos)); oldPos = pos + delimiter.size(); } while (pos != std::string::npos); return c; } #endif // UTILITY_STRING_H