Mercurial > repos > aaronquinlan > multi_intersect
comparison BEDTools-Version-2.14.3/src/utils/Fasta/split.cpp @ 1:bec36315bd12 default tip
Deleted selected files
| author | aaronquinlan |
|---|---|
| date | Sat, 19 Nov 2011 14:17:03 -0500 |
| parents | dfcd8b6c1bda |
| children |
comparison
equal
deleted
inserted
replaced
| 0:dfcd8b6c1bda | 1:bec36315bd12 |
|---|---|
| 1 #include "split.h" | |
| 2 | |
| 3 std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems) { | |
| 4 std::stringstream ss(s); | |
| 5 std::string item; | |
| 6 while(std::getline(ss, item, delim)) { | |
| 7 elems.push_back(item); | |
| 8 } | |
| 9 return elems; | |
| 10 } | |
| 11 | |
| 12 std::vector<std::string> split(const std::string &s, char delim) { | |
| 13 std::vector<std::string> elems; | |
| 14 return split(s, delim, elems); | |
| 15 } | |
| 16 | |
| 17 std::vector<std::string> &split(const std::string &s, const std::string& delims, std::vector<std::string> &elems) { | |
| 18 char* tok; | |
| 19 char cchars [s.size()+1]; | |
| 20 char* cstr = &cchars[0]; | |
| 21 strcpy(cstr, s.c_str()); | |
| 22 tok = strtok(cstr, delims.c_str()); | |
| 23 while (tok != NULL) { | |
| 24 elems.push_back(tok); | |
| 25 tok = strtok(NULL, delims.c_str()); | |
| 26 } | |
| 27 return elems; | |
| 28 } | |
| 29 | |
| 30 std::vector<std::string> split(const std::string &s, const std::string& delims) { | |
| 31 std::vector<std::string> elems; | |
| 32 return split(s, delims, elems); | |
| 33 } |
