tools.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include <iostream>
  2. #include <string>
  3. #include "tools.h"
  4. namespace Tools
  5. {
  6. // #ifdef _UNICODE
  7. // // 来源:https://www.cnblogs.com/happykoukou/p/5427268.html
  8. // //字符串分割函数
  9. // //因为只用到了坐标分割,所以这个版本的split不是很必要
  10. // std::vector<std::wstring> Tools::split(std::wstring str, std::wstring pattern)
  11. // {
  12. // std::wstring::size_type pos;
  13. // std::vector<std::wstring> result;
  14. // str += pattern;//扩展字符串以方便操作
  15. // size_t size = str.size();
  16. // for (size_t i = 0; i < size; i++)
  17. // {
  18. // pos = str.find(pattern, i);
  19. // if (pos < size)
  20. // {
  21. // std::wstring s = str.substr(i, pos - i);
  22. // result.push_back(s);
  23. // i = pos + pattern.size() - 1;
  24. // }
  25. // }
  26. // return result;
  27. // }
  28. //
  29. // #else
  30. // 字符串分割函数
  31. std::vector<std::string> split(std::string str, std::string pattern)
  32. {
  33. std::string::size_type pos;
  34. std::vector<std::string> result;
  35. str += pattern;//扩展字符串以方便操作
  36. size_t size = str.size();
  37. for (size_t i = 0; i < size; i++)
  38. {
  39. pos = str.find(pattern, i);
  40. if (pos < size)
  41. {
  42. std::string s = str.substr(i, pos - i);
  43. result.push_back(s);
  44. i = pos + pattern.size() - 1;
  45. }
  46. }
  47. return result;
  48. }
  49. FN_Proc GetFunc(_moduleType module, const char* funcName) {
  50. _moduleType mod = reinterpret_cast<_moduleType>(module);
  51. FN_Proc func;
  52. func = (FN_Proc)(::GetProcAddress(mod, funcName));
  53. return func;
  54. }
  55. // #endif
  56. }