common_api.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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 FindSortedSubFiles(string rootFile, vector<string> &filelist);
  27. void RawToHex(const char *pRaw, DWORD RawLen, string &Hex);
  28. string ReplaceSubString(string org, string &keystr, string &replacestr);
  29. string ReplaceFileTitle(string FilePath, string NewTitle);
  30. bool FindSubFiles(string rootDir, vector<string> &filelist, bool Recursive = true, string strWildcard = "*");
  31. template <class Type> bool StrToIntT(const char * str, Type *result)
  32. {
  33. Type value = 0;
  34. Type sign = 1;
  35. Type radix;
  36. if (str == NULL)
  37. {
  38. return false;
  39. }
  40. if (strlen(str) == 0)
  41. {
  42. return false;
  43. }
  44. if (*str == '-')
  45. {
  46. sign = -1;
  47. str++;
  48. }
  49. if (*str == '0' && (*(str + 1) == 'x' || *(str + 1) == 'X'))
  50. {
  51. radix = 16;
  52. str += 2;
  53. }
  54. //else if(*str == '0')
  55. //{
  56. // radix = 8;
  57. // str++;
  58. //}
  59. else
  60. {
  61. bool HitF = false;
  62. size_t Len = strlen(str);
  63. for (size_t i = 0; i < Len; i++)
  64. {
  65. if (str[i] >= '0' && str[i] <= '9')
  66. {
  67. continue;
  68. }
  69. HitF = true;
  70. break;
  71. }
  72. if (HitF)
  73. {
  74. radix = 16;
  75. }
  76. else
  77. {
  78. radix = 10;
  79. }
  80. }
  81. while (*str)
  82. {
  83. if (radix == 16)
  84. {
  85. if (*str >= '0' && *str <= '9')
  86. {
  87. value = value * radix + *str - '0';
  88. }
  89. else
  90. {
  91. if ((*str | 0x20) >= 'a' && (*str | 0x20) <= 'f')
  92. {
  93. value = value * radix + (*str | 0x20) - 'a' + 10;
  94. }
  95. else
  96. {
  97. return false;
  98. }
  99. }
  100. }
  101. else
  102. {
  103. value = value * radix + *str - '0';
  104. }
  105. str++;
  106. }
  107. *result = sign*value;
  108. return true;
  109. };
  110. class common_api
  111. {
  112. public:
  113. common_api(void);
  114. virtual ~common_api(void);
  115. HANDLE m_NotifyEvent;
  116. };