#ifndef GLOBALS_H #define GLOBALS_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "fmt/format.h" #if defined(_WIN32) || defined(__WIN32__) #include #define mkdir(A, B) _mkdir(A) #endif #define STRINGIFY(a) XSTRINGIFY(a) #define XSTRINGIFY(a) #a template static inline std::vector vector_of(T item) { return std::vector{item}; } typedef double nanoseconds_t; class Bytes; extern double getCurrentTime(); extern void hexdump(std::ostream& stream, const Bytes& bytes); extern void hexdumpForSrp16(std::ostream& stream, const Bytes& bytes); struct ErrorException { ErrorException(const std::string& message): message(message) {} const std::string message; void print() const; }; template [[noreturn]] inline void error(fmt::string_view fstr, const Args&... args) { throw ErrorException{fmt::format(fmt::runtime(fstr), args...)}; } extern void warning(const std::string msg); template inline void warning(fmt::string_view fstr, const Args&... args) { warning(fmt::format(fmt::runtime(fstr), args...)); } template struct overloaded : Ts... { using Ts::operator()...; }; template overloaded(Ts...) -> overloaded; #endif