From c2ac7fde673420555341fe79198b5900d72ab2bc Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Thu, 12 Jan 2017 20:28:44 +0100 Subject: [PATCH] refactor: Filesize strings --- include/modules/fs.hpp | 14 +++--- include/modules/memory.hpp | 15 ++++--- include/utils/math.hpp | 8 ++++ include/utils/string.hpp | 14 +++++- src/modules/fs.cpp | 34 ++++++-------- src/modules/memory.cpp | 75 +++++++++++-------------------- src/utils/string.cpp | 51 +++++++++++---------- tests/unit_tests/utils/string.cpp | 17 +++++++ 8 files changed, 116 insertions(+), 112 deletions(-) diff --git a/include/modules/fs.hpp b/include/modules/fs.hpp index 7134c852..ef6ad71a 100644 --- a/include/modules/fs.hpp +++ b/include/modules/fs.hpp @@ -17,15 +17,13 @@ namespace modules { string type; string fsname; - unsigned long long bytes_free = 0; - unsigned long long bytes_used = 0; - unsigned long long bytes_total = 0; + unsigned long long bytes_free{0ULL}; + unsigned long long bytes_used{0ULL}; + unsigned long long bytes_avail{0ULL}; + unsigned long long bytes_total{0ULL}; - float percentage_free = 0; - float percentage_used = 0; - - string percentage_free_s; - string percentage_used_s; + int percentage_free{0}; + int percentage_used{0}; explicit fs_mount(const string& mountpoint, bool mounted = false) : mountpoint(mountpoint), mounted(mounted) {} }; diff --git a/include/modules/memory.hpp b/include/modules/memory.hpp index 3ddc27dd..f4c46547 100644 --- a/include/modules/memory.hpp +++ b/include/modules/memory.hpp @@ -1,7 +1,7 @@ #pragma once -#include "settings.hpp" #include "modules/meta/timer_module.hpp" +#include "settings.hpp" POLYBAR_NS @@ -16,14 +16,15 @@ namespace modules { bool build(builder* builder, const string& tag) const; private: - static constexpr auto TAG_LABEL = "