StringUtils.cpp 671 B

1234567891011121314151617181920212223242526272829303132
  1. #include "StdInc.h"
  2. #include <vstd/StringUtils.h>
  3. namespace vstd
  4. {
  5. DLL_LINKAGE std::vector<std::string> split(std::string s, std::string separators)
  6. {
  7. std::vector<std::string> result;
  8. boost::split(result, s, boost::is_any_of(separators));
  9. return result;
  10. }
  11. DLL_LINKAGE std::pair<std::string, std::string> splitStringToPair(std::string input, char separator)
  12. {
  13. std::pair<std::string, std::string> ret;
  14. size_t splitPos = input.find(separator);
  15. if (splitPos == std::string::npos)
  16. {
  17. ret.first.clear();
  18. ret.second = input;
  19. }
  20. else
  21. {
  22. ret.first = input.substr(0, splitPos);
  23. ret.second = input.substr(splitPos + 1);
  24. }
  25. return ret;
  26. }
  27. }