#pragma once //#define _SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING #include #include #include #include #include #include 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 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 m_Times; // 时间段集合 bool isUsed; // 是否启用配置的时间段 bool isResetFreeTime; // 是否在挂机后开始计算空闲时间 static YamlConfig sp; };