FHConvert.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #pragma once
  2. #include <windows.h>
  3. #include <string>
  4. #include <cstdint>
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <assert.h>
  8. #include <cstddef>
  9. #include <vector>
  10. #include "dt.h"
  11. using std::string;
  12. #ifdef FH_CONVERT_EXPORTS
  13. #define FH_CONVERT_DLL_API __declspec(dllexport)
  14. #else
  15. #define FH_CONVERT_DLL_API //__declspec(dllimport)
  16. #endif
  17. class __declspec(dllexport) FHConvert
  18. {
  19. public:
  20. static unsigned short GetLowBit(unsigned int v);
  21. static unsigned short GetHightBit(unsigned int v);
  22. static unsigned int MergeHightLowBit(unsigned short hightbit, unsigned short lowbit);
  23. static double RoundDouble(double number, unsigned int bits);
  24. static LONG Char2Long(const CHAR *str);
  25. static INT Char2Int(const CHAR *str);
  26. static DOUBLE Char2Double(const CHAR *str);
  27. static bool Char2Bool(const CHAR *str);
  28. static LONG DoubleToLong(double value);
  29. //static void HexStr2Bytes(string hexStr,byte *byteStr,int byteLen);
  30. static int Unicode2Utf8(const wchar_t* wszString, char *szUtf8, int szLen);
  31. static int Utf82Unicode(const char* szUtf8, wchar_t *wszString, int wszLen);
  32. static int Ansi2Unicode(const char* szAnsi, wchar_t *wszString, int wszLen);
  33. static int Unicode2Ansi(const wchar_t* wszString, char *szAnsi, int szLen);
  34. static int Ansi2Utf8(const char* szAnsi,char *szUtf8, int szLen);
  35. static int Utf82Ansi(const char* szUtf8,char *szAnsi, int szLen);
  36. static int CopyStr(char *outbuf, int buflen, const char *format, ...);
  37. static unsigned long GetSysTime(void);
  38. static unsigned long DiffSysTime(unsigned long ulStime);
  39. static char* GetCurTime();
  40. static void GetCurTimeMill(char* pCurTime, int len);
  41. static unsigned long long GetSysTimeMill(void);
  42. static unsigned long long DiffSysTimeMill(unsigned long long ulStime);
  43. static void _Sleep(unsigned long ulDelay);
  44. //按分隔符,将字符串拆分为一个个数字
  45. static LONG ParseNumber(string strInput, CHAR chKey, std::vector<INT>& vecNum);
  46. static LONG ParseNumber(string strInput, CHAR chKey, std::vector<UINT>& vecNum);
  47. };