summaryrefslogtreecommitdiffhomepage
path: root/InfoEx/src/description.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'InfoEx/src/description.cpp')
-rw-r--r--InfoEx/src/description.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/InfoEx/src/description.cpp b/InfoEx/src/description.cpp
new file mode 100644
index 0000000..5635de5
--- /dev/null
+++ b/InfoEx/src/description.cpp
@@ -0,0 +1,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