first commit

This commit is contained in:
Vyn 2024-04-10 16:53:18 +02:00
commit 3e7d8b4b70
43 changed files with 2681 additions and 0 deletions

44
src/core/utils.cpp Normal file
View file

@ -0,0 +1,44 @@
/*
* Mirai. Copyright (C) 2024 Vyn
* This file is licensed under version 3 of the GNU General Public License (GPL-3.0-only)
* The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt
*/
#include "utils.h"
void ltrim(std::string& s) {
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) {
return !std::isspace(ch);
}));
}
void rtrim(std::string& s) {
s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char ch) {
return !std::isspace(ch);
}).base(), s.end());
}
void trim(std::string& s) {
rtrim(s);
ltrim(s);
}
std::string ltrim_copy(std::string s) {
ltrim(s);
return s;
}
std::string rtrim_copy(std::string s) {
rtrim(s);
return s;
}
std::string trim_copy(std::string s) {
trim(s);
return s;
}
bool isDate(const std::string& dateStr) {
std::regex regex("[0-9]{4}-[0-9]{2}-[0-9]{2}");
return std::regex_match(dateStr, regex);
}