#ifndef DEFS_HPP #define DEFS_HPP #include #include #include #include #if __has_include() #include #else #include "generator.hpp" #endif #include "spdlog/spdlog.h" #include "magic_enum.hpp" using std::operator""s; using std::operator""sv; enum class DataSource { CSDN, YAHOO }; struct Timer { std::chrono::time_point begin; std::string name; explicit Timer(std::string name) { spdlog::info("[{}] start...", name); this->name = name; this->begin = std::chrono::steady_clock::now(); } ~Timer() { auto end = std::chrono::steady_clock::now(); spdlog::info("[{}] time usage: {}ms", name, std::chrono::duration_cast(end - begin).count()); } }; // the fucking magic with macro #define CONCAT_IMPL(x, y) x##y #define MACRO_CONCAT(x, y) CONCAT_IMPL(x, y) #define timeit(name) std::shared_ptr MACRO_CONCAT(_timer_, __COUNTER__)(new Timer(name)) struct Cord { int x, y; bool operator==(const Cord &rhs) const { return x == rhs.x && y == rhs.y; } }; bool is_num(char c); bool is_alpha(char c); std::string tolower(const std::string &raw); std::generator passwords(const DataSource &source); void stat_date(const DataSource &source); void stat_keystroke(const DataSource &source); void stat_length(const DataSource &source); void stat_struct(const DataSource &source); void stat_word(const DataSource &source); #endif // DEFS_HPP