diff --git a/vutility.cpp b/vutility.cpp new file mode 100644 index 0000000..2769252 --- /dev/null +++ b/vutility.cpp @@ -0,0 +1,27 @@ +#include "vutility.hpp" + +std::vector vutility::split(std::string str, char delimit) +{ + std::vector 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) +{ + if (str.substr(0, 2) == "//") + { + str.erase(); + } + else + { + 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} + } + return str; +} \ No newline at end of file diff --git a/vutility.hpp b/vutility.hpp new file mode 100644 index 0000000..9beb3f5 --- /dev/null +++ b/vutility.hpp @@ -0,0 +1,13 @@ + +#include +#include +#include +class vutility +{ +private: + vutility() {} + +public: + static std::vector split(std::string str, char delimit); + static std::string trim(std::string str); +};