String.cxx
Go to the documentation of this file.
1 #include "WireCellUtil/String.h"
2 
3 using namespace std;
4 
5 std::vector<std::string> WireCell::String::split(const std::string& in, const std::string& delim)
6 {
7  vector<string> chunks;
8  if (in.empty()) {
9  return chunks;
10  }
11  boost::split(chunks, in, boost::is_any_of(delim), boost::token_compress_on);
12  return chunks;
13 }
14 
15 std::pair<std::string,std::string> WireCell::String::parse_pair(const std::string& in, const std::string& delim)
16 {
17  vector<string> chunks = split(in, delim);
18 
19  string first = chunks[0];
20  string second = "";
21  if (chunks.size() > 1) {
22  second = chunks[1];
23  }
24  return make_pair(first, second);
25 }
26 
27 
28 
29 // more:
30 // http://www.boost.org/doc/libs/1_60_0/doc/html/string_algo/quickref.html#idm45555128584624
string delim()
Definition: fcldump.cxx:41
std::string string
Definition: nybbler.cc:12
std::pair< std::string, std::string > parse_pair(const std::string &in, const std::string &delim=":")
Definition: String.cxx:15
STL namespace.
void split(std::string const &s, char c, OutIter dest)
Definition: split.h:35
std::vector< std::string > split(const std::string &in, const std::string &delim=":")
Definition: String.cxx:5
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:80