#include "common.h" using namespace std; vector split_line(const string& line, char delim) { vector result; size_t pos1; size_t pos2 = 0; while (pos2 != string::npos) { pos1 = pos2; pos2 = line.find(delim, pos1); if (pos2 != string::npos) { result.push_back(line.substr(pos1, pos2 - pos1)); ++pos2; } else { result.push_back(line.substr(pos1, pos2)); } } } string& clean_whitespace(string& str) { constexpr char whitespace[] = " \t\r\n\f\v"; size_t pos; pos = str.find_first_not_of(whitespace); str.erase(0, pos); pos = str.find_last_not_of(whitespace); str.erase(pos); return str; }