#pragma once #ifndef HELPERS_HPP #define HELPERS_HPP #include "esp_timer.h" #include #include #include #include #include namespace Helpers { char *itoa(int value, char *result, int base); void split(std::string str, std::string splitBy, std::vector &tokens); std::vector split(const std::string &s, char delimiter); /// @brief /// @tparam ...Args /// @param format /// @param ...args /// @return template std::string format_string(const std::string &format, Args... args) { int size_s = std::snprintf(nullptr, 0, format.c_str(), args...) + 1; // Extra space for '\0' if (size_s <= 0) { std::cout << "Error during formatting."; return ""; } auto size = static_cast(size_s); std::unique_ptr buf(new char[size]); std::snprintf(buf.get(), size, format.c_str(), args...); return std::string(buf.get(), buf.get() + size - 1); // We don't want the '\0' inside } int64_t getTimeInMillis(); } #endif // HELPERS_HPP