resourceIniParse.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #include <iostream>
  2. #include <vector>
  3. #include <fstream>
  4. #ifdef RVC_OS_WIN
  5. #include <windows.h>
  6. #endif // RVC_OS_WIN
  7. #ifndef MAX_PATH
  8. #define MAX_PATH 260
  9. #endif // !MAX_PATH
  10. using namespace std;
  11. #define HEADINI_NAME "HeadquartersLocalMediaPlay.ini"
  12. #define BRANCHINI_NAME "BranchLocalMediaPlay.ini"
  13. #define NETWORKINI_NAME "NetWorkLocalMediaPlay.ini"
  14. #define SECTION_GENERAL _T("General")
  15. #define GENERAL_MEDIANUM _T("MediaNum")
  16. #define SECTION_MEDIA _T("Media")
  17. #define MEDIA_TYPE _T("Type")
  18. #define MEDIA_FULLSCREEN _T("FullScreen")
  19. #define MEDIA_PRIMMONITOR _T("PrimMonitor")
  20. #define MEDIA_SIMPLEMODE _T("SimpleMode")
  21. #define MEDIA_PLAYINTERVAL _T("PlayInterval")
  22. #define MEDIA_VIDIONAMES _T("VideoNames")
  23. #define MEDIA_VAILDTIME _T("VaildTime")
  24. #define MEDIA_PLAYTIME _T("PlayTime")
  25. #define MEDIA_PRIORITY _T("priority")
  26. #define STR_NULL _T("")
  27. typedef struct _resourceParse
  28. {
  29. char type; //Pic:P, Video:V, Mp3:M
  30. bool fullScreen;
  31. bool primMonitor;
  32. bool simpleMode;
  33. int playInterval;
  34. string videoNames;
  35. string vaildTime;
  36. string playTime;
  37. int priority;
  38. string resourcePath;
  39. }ResourceParse;
  40. class CResourceParse {
  41. public:
  42. CResourceParse()
  43. {
  44. pvideoNames = NULL;
  45. pvaildTime = NULL;
  46. playTime = NULL;
  47. presourcePath = NULL;
  48. };
  49. CResourceParse(const CResourceParse& item)
  50. {
  51. this->type = item.type;
  52. this->fullScreen = item.fullScreen;
  53. this->primMonitor = item.primMonitor;
  54. this->simpleMode = item.simpleMode;
  55. this->playInterval = item.playInterval;
  56. this->priority = item.priority;
  57. if (item.pvideoNames) {
  58. this->pvideoNames = new char[strlen(item.pvideoNames) + 1];
  59. memset(this->pvideoNames, 0, strlen(item.pvideoNames) + 1);
  60. memcpy(this->pvideoNames, item.pvideoNames, strlen(item.pvideoNames));
  61. }
  62. if (item.pvaildTime) {
  63. this->pvaildTime = new char[strlen(item.pvaildTime) + 1];
  64. memset(this->pvaildTime, 0, strlen(item.pvaildTime) + 1);
  65. memcpy(this->pvaildTime, item.pvaildTime, strlen(item.pvaildTime));
  66. }
  67. if (item.playTime) {
  68. this->playTime = new char[strlen(item.playTime) + 1];
  69. memset(this->playTime, 0, strlen(item.playTime) + 1);
  70. memcpy(this->playTime, item.playTime, strlen(item.playTime));
  71. }
  72. if (item.presourcePath) {
  73. this->presourcePath = new char[strlen(item.presourcePath) + 1];
  74. memset(this->presourcePath, 0, strlen(item.presourcePath) + 1);
  75. memcpy(this->presourcePath, item.presourcePath, strlen(item.presourcePath));
  76. }
  77. };
  78. ~CResourceParse()
  79. {
  80. if (pvideoNames) delete[]pvideoNames;
  81. if (pvaildTime) delete[]pvaildTime;
  82. if (playTime) delete[]playTime;
  83. if (presourcePath) delete[]presourcePath;
  84. };
  85. char type; //Pic:P, Video:V, Mp3:M
  86. bool fullScreen;
  87. bool primMonitor;
  88. bool simpleMode;
  89. int playInterval;
  90. int priority;
  91. char* pvideoNames;
  92. char* pvaildTime;
  93. char* playTime;
  94. char* presourcePath;
  95. };
  96. typedef struct rvcResourceParse_s {
  97. char type; //Pic:P, Video:V, Mp3:M
  98. bool fullScreen;
  99. bool primMonitor;
  100. bool simpleMode;
  101. int playInterval;
  102. int priority;
  103. char strvideoNames[MAX_PATH];
  104. char strvaildTime[64];
  105. char strplayTime[64];
  106. char strResourcePath[MAX_PATH];
  107. }rvcResourceParse_t;
  108. bool checkInPlayTime(string playTime, bool checkCurTime = false);
  109. bool parseResourceIni(const char* filePath, vector<ResourceParse> &ret);
  110. bool checkInVaildTime(string vaildTime, bool checkCurData = false);