Introduce a helper routine which splits a string into tokens that were
separated by a delimiter.
return s;
}
+/**
+ * Split a string into tokens at occurances of the separator.
+ *
+ * @param[in] text the input string to split
+ * @param[in] separator the delimiter between tokens
+ *
+ * @return a vector of broken down tokens
+ */
+vector<string> split_string(string text, string separator)
+{
+ vector<string> result;
+ size_t pos;
+
+ while ((pos = text.find(separator)) != std::string::npos) {
+ result.push_back(text.substr(0, pos));
+ text = text.substr(pos + separator.length());
+ }
+ result.push_back(text);
+
+ return result;
+}
+
} // namespace util
} // namespace pv
#define PULSEVIEW_UTIL_HPP
#include <cmath>
+#include <string>
+#include <vector>
#ifndef Q_MOC_RUN
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <QMetaType>
#include <QString>
+using std::string;
+using std::vector;
+
namespace pv {
namespace util {
QString format_time_minutes(const Timestamp& t, signed precision = 0,
bool sign = true);
+vector<string> split_string(string text, string separator);
+
} // namespace util
} // namespace pv