| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- #pragma once
- //#define _SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING
- #include <yaml-cpp/yaml.h>
- #include <iostream>
- #include <string>
- #include <fstream>
- #include <map>
- #include <boost/noncopyable.hpp>
- using namespace std;
- #pragma comment(lib,"libyaml-cppmd-mt.lib")
- #define YAMLCONFIGFILEPATH "ACD.yml"
- class YamlConfig :public boost::noncopyable
- {
- private:
- YamlConfig();
- ~YamlConfig();
- bool ReadConfig();
- public:
-
- map<string, string> GetTimeMap() { return m_Times; };
- bool GetIsUsed()const { return isUsed; };
- bool GetIsResetFreeTime()const { return isResetFreeTime; }
- static CTime timestr(const char* str,int offset = 0)
- {
- USES_CONVERSION;
- int nYear, nMonth, nDate, nHour, nMin, nSec;
- nYear = nMonth = nDate = nHour = nMin = nSec = 0;
- sscanf_s(str, "%d-%d-%d %d:%d:%d", &nYear, &nMonth, &nDate, &nHour, &nMin, &nSec);
- CTime t(nYear, nMonth, nDate + offset, nHour, nMin, nSec);
- return t;
- }
- static YamlConfig* GetInstance() { return &sp; };
- private:
- map<string, string> m_Times; // 时间段集合
- bool isUsed; // 是否启用配置的时间段
- bool isResetFreeTime; // 是否在挂机后开始计算空闲时间
- static YamlConfig sp;
- };
|