2020-08-18 19:00:26 +05:30
|
|
|
#include "vutility.hpp"
|
|
|
|
|
|
|
|
|
|
std::vector<std::string> vutility::split(std::string str, char delimit)
|
|
|
|
|
{
|
|
|
|
|
std::vector<std::string> tokens;
|
|
|
|
|
std::stringstream tokenizer(str);
|
|
|
|
|
std::string intermediate;
|
|
|
|
|
while (std::getline(tokenizer, intermediate, delimit))
|
|
|
|
|
{
|
|
|
|
|
tokens.push_back(intermediate);
|
|
|
|
|
}
|
|
|
|
|
return tokens;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string vutility::trim(std::string str)
|
|
|
|
|
{
|
2020-08-21 17:56:06 +05:30
|
|
|
if (str.find('/') != std::string::npos) // comments
|
2020-08-18 19:00:26 +05:30
|
|
|
{
|
2020-08-21 17:56:06 +05:30
|
|
|
str.erase(str.find('/'));
|
2020-08-18 19:00:26 +05:30
|
|
|
}
|
2020-08-21 17:56:06 +05:30
|
|
|
str.erase(0, str.find_first_not_of(" \r\t\v\n")); //prefixing
|
|
|
|
|
str.erase(str.find_last_not_of(" \r\t\v\n") + 1); //surfixing}
|
|
|
|
|
|
2020-08-18 19:00:26 +05:30
|
|
|
return str;
|
|
|
|
|
}
|