create separate header for string util functions
This commit is contained in:
parent
9a75404847
commit
ad03011871
2 changed files with 22 additions and 5 deletions
20
include/string_util.hpp
Normal file
20
include/string_util.hpp
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef PP_DEBUG
|
||||||
|
#include <algorithm>
|
||||||
|
#include <string>
|
||||||
|
#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;
|
||||||
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
#include <osuparser.hpp>
|
#include <osuparser.hpp>
|
||||||
|
|
||||||
|
#include <string_util.hpp>
|
||||||
|
|
||||||
#ifndef PP_DEBUG
|
#ifndef PP_DEBUG
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
@ -23,11 +25,6 @@ inline std::string checkAndRemove(const std::string &str, const std::string &pre
|
||||||
return trimString(str.substr(prefix.length()));
|
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, ...) \
|
#define CONFIG(name, ...) \
|
||||||
name parse##name(fs::path configPath) {\
|
name parse##name(fs::path configPath) {\
|
||||||
if (!fs::exists(configPath)) {\
|
if (!fs::exists(configPath)) {\
|
||||||
|
|
Loading…
Reference in a new issue