StringList.cpp 782 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include "anki/util/StringList.h"
  2. #include <boost/tokenizer.hpp>
  3. namespace anki {
  4. //==============================================================================
  5. StringList::StringType StringList::join(const StringType& sep) const
  6. {
  7. StringType out;
  8. Base::const_iterator it = begin();
  9. for(; it != end(); it++)
  10. {
  11. out += *it;
  12. if(it != end() - 1)
  13. {
  14. out += sep;
  15. }
  16. }
  17. return out;
  18. }
  19. //==============================================================================
  20. StringList StringList::splitString(const StringType& s, const char* seperators)
  21. {
  22. typedef boost::char_separator<char> Sep;
  23. typedef boost::tokenizer<Sep> Tok;
  24. Sep sep(seperators);
  25. StringList out;
  26. Tok tok(s, sep);
  27. for(auto s: tok)
  28. {
  29. out.push_back(s);
  30. }
  31. return out;
  32. }
  33. } // end namespace