Mercurial > repos > aaronquinlan > multi_intersect
diff BEDTools-Version-2.14.3/src/utils/Fasta/split.cpp @ 0:dfcd8b6c1bda
Uploaded
author | aaronquinlan |
---|---|
date | Thu, 03 Nov 2011 10:25:04 -0400 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BEDTools-Version-2.14.3/src/utils/Fasta/split.cpp Thu Nov 03 10:25:04 2011 -0400 @@ -0,0 +1,33 @@ +#include "split.h" + +std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems) { + std::stringstream ss(s); + std::string item; + while(std::getline(ss, item, delim)) { + elems.push_back(item); + } + return elems; +} + +std::vector<std::string> split(const std::string &s, char delim) { + std::vector<std::string> elems; + return split(s, delim, elems); +} + +std::vector<std::string> &split(const std::string &s, const std::string& delims, std::vector<std::string> &elems) { + char* tok; + char cchars [s.size()+1]; + char* cstr = &cchars[0]; + strcpy(cstr, s.c_str()); + tok = strtok(cstr, delims.c_str()); + while (tok != NULL) { + elems.push_back(tok); + tok = strtok(NULL, delims.c_str()); + } + return elems; +} + +std::vector<std::string> split(const std::string &s, const std::string& delims) { + std::vector<std::string> elems; + return split(s, delims, elems); +}