-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathparseCPUIDArgs.h
40 lines (30 loc) · 1.12 KB
/
parseCPUIDArgs.h
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
#pragma once
#include <Physics3D/misc/cpuid.h>
#include "cmdParser.h"
#include <string>
namespace Util {
inline std::string printAndParseCPUIDArgs(const ParsedArgs& cmdArgs) {
std::string message("Detected CPU Technologies: ");
for(size_t i = 0; i < P3D::CPUIDCheck::TECHNOLOGY_COUNT; i++) {
if(P3D::CPUIDCheck::hasTechnology(1U << i)) message.append(P3D::CPUIDCheck::NAMES[i]).append(" ");
}
bool disabledSomething = false;
for(int techI = 0; techI < P3D::CPUIDCheck::TECHNOLOGY_COUNT; techI++) {
if(cmdArgs.hasFlag(P3D::CPUIDCheck::NAMES[techI])) {
P3D::CPUIDCheck::disableTechnology(1 << techI);
message.append("\nDisabled technology -").append(P3D::CPUIDCheck::NAMES[techI]);
disabledSomething = true;
}
}
if(disabledSomething) {
message.append("\nEnabled CPU Technologies: ");
for(size_t i = 0; i < P3D::CPUIDCheck::TECHNOLOGY_COUNT; i++) {
if(P3D::CPUIDCheck::hasTechnology(1U << i)) message.append(P3D::CPUIDCheck::NAMES[i]).append(" ");
}
}
return message;
}
inline std::string printAndParseCPUIDArgs(int argc, const char** argv) {
return printAndParseCPUIDArgs(ParsedArgs(argc, argv));
}
};