summaryrefslogtreecommitdiff
path: root/src/helpers/MiscFunctions.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/helpers/MiscFunctions.cpp')
-rw-r--r--src/helpers/MiscFunctions.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp
index 29861af7..878f5ca1 100644
--- a/src/helpers/MiscFunctions.cpp
+++ b/src/helpers/MiscFunctions.cpp
@@ -863,3 +863,10 @@ bool allocateSHMFilePair(size_t size, int* rw_fd_ptr, int* ro_fd_ptr) {
*ro_fd_ptr = ro_fd;
return true;
}
+
+float stringToPercentage(const std::string& VALUE, const float REL) {
+ if (VALUE.ends_with('%'))
+ return (std::stof(VALUE.substr(0, VALUE.length() - 1)) * REL) / 100.f;
+ else
+ return std::stof(VALUE);
+};