中间件底层,websocket

YamlConfig.h 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #pragma once
  2. //#define _SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING
  3. #include <yaml-cpp/yaml.h>
  4. #include <iostream>
  5. #include <string>
  6. #include <fstream>
  7. #include <map>
  8. #include <boost/noncopyable.hpp>
  9. using namespace std;
  10. #pragma comment(lib,"libyaml-cppmd-mt.lib")
  11. #define YAMLCONFIGFILEPATH "ACD.yml"
  12. class YamlConfig :public boost::noncopyable
  13. {
  14. private:
  15. YamlConfig();
  16. ~YamlConfig();
  17. bool ReadConfig();
  18. public:
  19. map<string, string> GetTimeMap() { return m_Times; };
  20. bool GetIsUsed()const { return isUsed; };
  21. bool GetIsResetFreeTime()const { return isResetFreeTime; }
  22. static CTime timestr(const char* str,int offset = 0)
  23. {
  24. USES_CONVERSION;
  25. int nYear, nMonth, nDate, nHour, nMin, nSec;
  26. nYear = nMonth = nDate = nHour = nMin = nSec = 0;
  27. sscanf_s(str, "%d-%d-%d %d:%d:%d", &nYear, &nMonth, &nDate, &nHour, &nMin, &nSec);
  28. CTime t(nYear, nMonth, nDate + offset, nHour, nMin, nSec);
  29. return t;
  30. }
  31. static YamlConfig* GetInstance() { return &sp; };
  32. private:
  33. map<string, string> m_Times; // 时间段集合
  34. bool isUsed; // 是否启用配置的时间段
  35. bool isResetFreeTime; // 是否在挂机后开始计算空闲时间
  36. static YamlConfig sp;
  37. };