You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
737 B
24 lines
737 B
#ifndef _UTIL_
|
|
#define _UTIL_
|
|
|
|
#include <vector>
|
|
#include <string>
|
|
|
|
namespace util {
|
|
const std::vector<std::string> split(const std::string input, const std::string::value_type separator, const size_t max_tokens = -1);
|
|
const std::string lpad(const std::string input, const int length = 1, const std::string str = " ");
|
|
|
|
template <class RangeT>
|
|
const std::string join(RangeT & range, const std::string::value_type separator) {
|
|
std::string output;
|
|
for(auto element = range.begin(); element != range.end(); ++element) {
|
|
if(element != range.begin()) {
|
|
output.push_back(separator);
|
|
}
|
|
output.append(*element);
|
|
}
|
|
return output;
|
|
}
|
|
};
|
|
|
|
#endif |