Skip to content

Instantly share code, notes, and snippets.

@yanivmo
Last active December 14, 2015 00:09
Show Gist options
  • Save yanivmo/4996525 to your computer and use it in GitHub Desktop.
Save yanivmo/4996525 to your computer and use it in GitHub Desktop.
Parse a string of comma separated values using C++03 Standard Library only
std::set<std::string> CMService::getDirContents(const std::string& path)
{
RepositoryService repository;
//RepositoryService::getDirContents returns CSVs in a string
std::stringstream contentsCsv(repository.getDirContents(path));
std::string entry;
std::set<std::string> entries;
while (std::getline(contentsCsv, entry, ',')) {
entries.insert(entry);
}
return entries;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment