Skip to content
Snippets Groups Projects
Commit daef10e3 authored by Karsten Rink's avatar Karsten Rink
Browse files

added alternate method for deconstucting string into a vector of words

parent 8b5f4585
No related branches found
No related tags found
No related merge requests found
......@@ -25,6 +25,16 @@
namespace BaseLib
{
std::vector<std::string> splitString(std::string const& str)
{
std::istringstream str_stream(str);
std::vector<std::string> items;
std::copy(std::istream_iterator<std::string>(str_stream),
std::istream_iterator<std::string>(),
std::back_inserter(items));
return items;
}
std::list<std::string> splitString(const std::string &str, char delim)
{
std::list<std::string> strList;
......
......@@ -19,9 +19,18 @@
#include <string>
#include <list>
#include <sstream>
#include <vector>
namespace BaseLib {
/**
* Splits a string into a vector of strings. This method only works for string seperation
* recognised by the std::stringstream iterator such as ' ' or '\t'.
* \param str String to be splitted
* \return Vector of strings
*/
std::vector<std::string> splitString(std::string const& str);
/**
* Splits a string into a list of strings.
* \param str String to be splitted
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment