a lot of fixes

This commit is contained in:
2024-10-05 13:52:44 +03:00
parent 640337d420
commit d2afa8c9dd
32 changed files with 909 additions and 104 deletions

View File

@@ -1,8 +1,8 @@
#include "utils.h"
#include <codecvt>
#include <string>
#include <locale>
#include <string>
std::string to_utf8(std::wstring wide_string) {
static std::wstring_convert<std::codecvt_utf8<wchar_t>> utf8_conv;
@@ -13,3 +13,18 @@ std::wstring from_utf8(std::string string) {
static std::wstring_convert<std::codecvt_utf8<wchar_t>> utf8_conv;
return utf8_conv.from_bytes(string);
}
std::string get_path_relative_to_home(std::string path) {
return std::string(std::getenv("HOME")) + "/" + path;
}
template <typename T>
bool vector_contains_element(const std::vector<T>& vector, const T& to_find) {
for (const T& element : vector) {
if (element == to_find) return true;
}
return false;
}
//ужас
template bool vector_contains_element<std::string>(const std::vector<std::string>& vector, const std::string& to_find);

View File

@@ -2,8 +2,14 @@
#define UTILS_H
#include <string>
#include <vector>
std::string to_utf8(std::wstring wide_string);
std::wstring from_utf8(std::string string);
std::string get_path_relative_to_home(std::string path);
template <typename T>
bool vector_contains_element(const std::vector<T> &vector, const T &to_find);
#endif // UTILS_H