Advertisement
Vultraz

Untitled

Oct 16th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. Basic method taken from http://stackoverflow.com/a/236803
  2.  
  3. std::vector<std::string> split(const std::string& val, const char c, const int flags)
  4. {
  5.     std::vector<std::string> res;
  6.  
  7.     std::stringstream ss;
  8.     ss.str(val);
  9.  
  10.     std::string item;
  11.     while(std::getline(ss, item, c)) {
  12.         if(flags & STRIP_SPACES) {
  13.             boost::trim(item);
  14.         }
  15.  
  16.         if(!(flags & REMOVE_EMPTY) || !item.empty()) {
  17.             res.push_back(std::move(item));
  18.         }
  19.     }
  20.  
  21.     return res;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement