common_api.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. #pragma once
  2. #include <map>
  3. #include <string>
  4. #include <Rpc.h>
  5. #include <vector>
  6. #include "ResDataObject.h"
  7. using namespace std;
  8. bool AddEnvPath(const char *pPath);
  9. UINT64 GetDay(UINT64 TheTime);
  10. __time64_t GetCurrentRealTimeOfStk();
  11. int CompareTimeByDay(UINT64 Prev, UINT64 Cur);
  12. bool string_2_guid(const char *pstr, GUID &stGuid);
  13. bool guid_2_string(GUID &stGuid, string &str);
  14. bool SplitString(const char *pString, string args, vector<string> &nodes);
  15. bool SplitTo84422222222String(const char *pString, vector<string> &nodes);
  16. bool CreateFileDirectory(string &FullFilePath);
  17. string FormatstdString(const char *pcFormat, ...);
  18. bool getBusIdFromFilePath(const char *pFilePath,string &BusId);
  19. bool SplitDevicePath(const char *pDevicePath, vector<string> &nodes);
  20. bool MergeDevicePath(vector<string> &nodes, string &Devpath);
  21. string GetProcessDirectory();
  22. string GetFileTitle(string &fullpath);
  23. string GetFileName(string &fullpath);
  24. string & makeLowerStr(string & src);
  25. string GetFileDirectory(string &fullpath);
  26. bool FindSubVersionDirs(string rootDir, map<string, vector<string>>& dirlist);
  27. bool FindSortedSubFiles(string rootFile, vector<string> &filelist);
  28. void RawToHex(const char *pRaw, DWORD RawLen, string &Hex);
  29. string ReplaceSubString(string org, string &keystr, string &replacestr);
  30. string ReplaceFileTitle(string FilePath, string NewTitle);
  31. bool FindSubFiles(string rootDir, vector<string> &filelist, bool Recursive = true, string strWildcard = "*");
  32. template <class Type> bool StrToIntT(const char * str, Type *result)
  33. {
  34. Type value = 0;
  35. Type sign = 1;
  36. Type radix;
  37. if (str == NULL)
  38. {
  39. return false;
  40. }
  41. if (strlen(str) == 0)
  42. {
  43. return false;
  44. }
  45. if (*str == '-')
  46. {
  47. sign = -1;
  48. str++;
  49. }
  50. if (*str == '0' && (*(str + 1) == 'x' || *(str + 1) == 'X'))
  51. {
  52. radix = 16;
  53. str += 2;
  54. }
  55. //else if(*str == '0')
  56. //{
  57. // radix = 8;
  58. // str++;
  59. //}
  60. else
  61. {
  62. bool HitF = false;
  63. size_t Len = strlen(str);
  64. for (size_t i = 0; i < Len; i++)
  65. {
  66. if (str[i] >= '0' && str[i] <= '9')
  67. {
  68. continue;
  69. }
  70. HitF = true;
  71. break;
  72. }
  73. if (HitF)
  74. {
  75. radix = 16;
  76. }
  77. else
  78. {
  79. radix = 10;
  80. }
  81. }
  82. while (*str)
  83. {
  84. if (radix == 16)
  85. {
  86. if (*str >= '0' && *str <= '9')
  87. {
  88. value = value * radix + *str - '0';
  89. }
  90. else
  91. {
  92. if ((*str | 0x20) >= 'a' && (*str | 0x20) <= 'f')
  93. {
  94. value = value * radix + (*str | 0x20) - 'a' + 10;
  95. }
  96. else
  97. {
  98. return false;
  99. }
  100. }
  101. }
  102. else
  103. {
  104. value = value * radix + *str - '0';
  105. }
  106. str++;
  107. }
  108. *result = sign*value;
  109. return true;
  110. };
  111. class common_api
  112. {
  113. public:
  114. common_api(void);
  115. virtual ~common_api(void);
  116. HANDLE m_NotifyEvent;
  117. };