-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDllExport.cpp
More file actions
46 lines (39 loc) · 1.27 KB
/
DllExport.cpp
File metadata and controls
46 lines (39 loc) · 1.27 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
#include "DllExport.h"
#include "IniFile.h"
#include "Log.h"
#include "Settings.h"
#include "Checker.h"
using BOOL = int;
Validator& Validator::Instance() {
static Validator inst;
return inst;
}
void Validator::LoadBootSetting(const std::string& path) {
bootSettingIni = std::make_unique<IniFile>(path, true);// will set into global instance
bootSettings = std::make_unique<Settings>(*bootSettingIni);
}
void Validator::ReloadConfigRule(const std::string& path) {
configIni = std::make_unique<IniFile>(path, true);
}
bool Validator::Validate(
const std::string& targetFilePath,
ValidationResults& results) {
if (!configIni)
return false;
IniFile targetIni;
IniFile::FileType = "rules";
targetIni.load(targetFilePath, true);
Checker checker(*configIni, targetIni, false);
checker.checkFile();
results.resize(static_cast<int>(ValidationSeverity::__Count));
for (auto idx = 0u; idx < ValidationSeverity::__Count; ++idx) {
results[idx].severity = ValidationSeverity(idx);
}
for (const auto& log : Log::Logs) {
auto&& msg = log.getFileMessage();
auto const severity = static_cast<int>(log.getSeverity());
auto& result = results[severity];
result.details.emplace_back(std::move(msg));
}
return results[static_cast<int>(ValidationSeverity::Error)].details.size() == 0;
}