summaryrefslogtreecommitdiffhomepage
path: root/InfoEx/src/description.cpp
blob: 5635de50d3acc4462fc3d933fbf0cd36efa49505 (plain)
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
51
52
53
#include <InfoEx.h>

#include <infoware/infoware.hpp>

#include <Text.h>


namespace
{


static constexpr const char* prefixes[] {"", "k", "M", "G", "T", "P", "E", "Z", "Y", "R", "Q"};


Text
HumanReadable(long double value, const char* unit)
{
	int magnitude = 0;
	while (value > 1000) {
		value /= 1000;
		magnitude++;
	}
	return Text::format("%.2Lf %s%s", value, prefixes[magnitude], unit);
}


}  // namespace


namespace InfoEx
{


Text
ShortDescription()
{
	return iware::system::OS_info().full_name.data();
}


Text
LongDescription()
{
	return Text::format(
		"OS: %s\nPhysical memory: %s\nCPU: %s\nCPU frequency: %s",
		iware::system::OS_info().full_name.data(),
		HumanReadable(iware::system::memory().physical_total, "B").data(),
		iware::cpu::model_name().data(),
		HumanReadable(iware::cpu::frequency(), "Hz").data());
}


}  // namespace InfoEx