ppap4lmp  0.7.2
split.cpp
Go to the documentation of this file.
1 
8 #include <sstream>
9 
10 #include "split.h"
11 
12 namespace ut = utils;
13 
14 /* ------------------------------------------------------------------ */
15 
17  const Str &str,
18  char delim)
19 {
20  Vec<Str> tmp;
21 
22  std::stringstream ss(str);
23  Str item;
24 
25  while (getline(ss, item, delim))
26  {
27  if (!item.empty())
28  {
29  tmp.push_back(item);
30  }
31  }
32 
33  return tmp;
34 }
This file has a definition of utils::split.
Vec< Str > split(const Str &str, char delim=' ')
Mimicking Python&#39;s split.
Definition: split.cpp:16
std::string Str
Str is an alias for string.
Definition: std.h:21
std::vector< T > Vec
Vec is an alias for vector (same as list in Python).
Definition: std.h:27
Namespace for utility functions.
Definition: join.h:14