util.h 918 B

1234567891011121314151617181920212223242526272829303132333435
  1. #pragma once
  2. #include <regex>
  3. #include <filesystem>
  4. #include <string>
  5. #include <vector>
  6. #include <fstream>
  7. #include <sstream>
  8. #include <chrono>
  9. #include "Logger.h"
  10. #define SAFE_BEGIN() __try {
  11. #define SAFE_ERROR() } __except (EXCEPTION_EXECUTE_HANDLER) { \
  12. LOG_WARNING("Exception 0x%08x.", GetExceptionCode());
  13. #define SAFE_END() }
  14. #define SAFE_EEND() SAFE_ERROR(); SAFE_END();
  15. namespace util {
  16. std::string getUAHash(std::string execPath);
  17. std::vector<std::string> split(const std::string& content, const std::string& delimiter);
  18. int64_t GetCurrentTimeMillisec();
  19. std::string ConvertToWords(const std::string& input);
  20. std::string FirstCharToLowercase(std::string string);
  21. template <typename T>
  22. const char* get_ptr(const T& value) {
  23. std::stringstream ss;
  24. ss << std::hex << std::showbase << reinterpret_cast<const void*>(value);
  25. static std::string result = ss.str();
  26. return result.c_str();
  27. }
  28. }