-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfFile.h
More file actions
50 lines (43 loc) · 1.44 KB
/
ConfFile.h
File metadata and controls
50 lines (43 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* Copyright (C) Hauck Software Solutions - All Rights Reserved
* You may use, distribute and modify this code under the terms
* that changes to the code must be reported back the original
* author
*
* Company: Hauck Software Solutions
* Author: Thomas Hauck
* Email: Thomas@fam-hauck.de
*
*/
#pragma once
#include <map>
#include <unordered_map>
#include <string>
#include <vector>
#include <mutex>
using namespace std;
class ConfFile
{
public:
static const ConfFile& GetInstance(const wstring& strConfigFile);
ConfFile(const ConfFile& src);
virtual ~ConfFile();
vector<wstring> get() const;
vector<wstring> get(const wstring& strSektion) const;
vector<wstring> get(const wstring& strSektion, const wstring& strValue) const;
const wstring& getUnique(const wstring& strSektion, const wstring& strValue) const;
private:
ConfFile() = delete;
explicit ConfFile(const wstring& strConfigFile) : m_strFileName(strConfigFile), m_tFileTime(0) {}
ConfFile& operator=(ConfFile&&) = delete;
ConfFile& operator=(const ConfFile&) = delete;
void CheckFileLoaded() const;
void LoadFile(const wstring& strFilename);
bool AreFilesModifyed() const;
private:
wstring m_strFileName;
mutex m_mtxLoad;
chrono::steady_clock::time_point m_tLastCheck;
time_t m_tFileTime;
unordered_map<wstring, unordered_multimap<wstring, wstring>> m_mSections;
static map<wstring, ConfFile> s_lstConfFiles;
};