From ad030118716d66f9c220b59417ffca519632889d Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Thu, 25 Apr 2024 22:34:51 +0200 Subject: [PATCH] create separate header for string util functions --- include/string_util.hpp | 20 ++++++++++++++++++++ src/osuparser.cpp | 7 ++----- 2 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 include/string_util.hpp diff --git a/include/string_util.hpp b/include/string_util.hpp new file mode 100644 index 0000000..7280251 --- /dev/null +++ b/include/string_util.hpp @@ -0,0 +1,20 @@ +#pragma once + +#ifndef PP_DEBUG +#include +#include +#endif + +inline void toLower(std::string &str) { + std::transform(str.begin(), str.end(), str.begin(), + [](unsigned char c){ return std::tolower(c); }); +} + +inline void toUpper(std::string &str) { + std::transform(str.begin(), str.end(), str.begin(), + [](unsigned char c){ return std::toupper(c); }); +} + +inline bool isInt(const std::string &str) { + return str.find_first_not_of("1234567890") == std::string::npos; +} diff --git a/src/osuparser.cpp b/src/osuparser.cpp index cd82a89..235eb44 100644 --- a/src/osuparser.cpp +++ b/src/osuparser.cpp @@ -1,5 +1,7 @@ #include +#include + #ifndef PP_DEBUG #include #include @@ -23,11 +25,6 @@ inline std::string checkAndRemove(const std::string &str, const std::string &pre return trimString(str.substr(prefix.length())); } -inline void toLower(std::string &str) { - std::transform(str.begin(), str.end(), str.begin(), - [](unsigned char c){ return std::tolower(c); }); -} - #define CONFIG(name, ...) \ name parse##name(fs::path configPath) {\ if (!fs::exists(configPath)) {\