Commit d61fb443c138957656d3a86c3d1a693cdad2385c

Authored by Jordi Inglada
1 parent 40fd93e0
Exists in master

ENH: join a vector of strings into a string

Showing 1 changed file with 11 additions and 1 deletions   Show diff stats
include/cbutils.h
... ... @@ -39,7 +39,17 @@ std::vector<std::string> split(const std::string& str,
39 39 boost::token_compress_on);
40 40 return tokens;
41 41 }
42   -
  42 +// Joins a vector of strings into a string
  43 +std::string join(const std::vector<std::string>& vos, char sep=' ')
  44 +{
  45 + std::stringstream ss;
  46 + ss << vos[0];
  47 + for(size_t i=1; i<vos.size(); ++i)
  48 + {
  49 + ss << sep << vos[i];
  50 + }
  51 + return ss.str();
  52 +}
43 53 } //end ns string
44 54 // ----------------- File IO ---------------------------------------------------
45 55 namespace file
... ...