#ifndef UTIL_H #define UTIL_H #ifndef NULL #define NULL ((void*)0) #endif #include #include #include #include #include #include #include std::string intToString(int theInt); std::string replaceExEscape(std::string first, std::string search, std::string replace); std::string strSlice(std::string str, int begin, int end); int findPerenEnd(std::string str, int i); std::vector split(const std::string &str, char delim); std::string join(const std::vector &strVec, std::string joinStr); std::string readFile(std::istream &file); std::string padWithSpaces(std::string str, int padTo); template bool contains(std::vector vec, T item) { for (auto i : vec) if (i == item) return true; return false; } template std::vector slice(std::vector vec, int begin, int end, int step = 1) { std::vector toReturn; if (begin < 0) begin += vec.size()+1; if (end < 0) end += vec.size()+1; for (int i = begin; i < end; i += step) toReturn.push_back(vec[i]); return toReturn; } template bool subset(std::set a, std::set b) { for (auto i : a) if (b.find(i) == b.end()) return false; return true; } #endif