16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-21 22:59:19 +02:00

Some renaming

This commit is contained in:
2025-04-15 01:32:56 +02:00
parent 12d6a1578d
commit a39d972126
864 changed files with 29 additions and 34 deletions

View File

@@ -0,0 +1,31 @@
#pragma once
#include <yaml-cpp/yaml.h>
#include <string>
inline std::wstring ToWide(const std::string& str) {
std::wstring wstr{};
wstr.resize(std::mbstowcs(nullptr, str.c_str(), static_cast<uint64_t>(-1)));
std::mbstowcs(wstr.data(), str.c_str(), wstr.size());
return wstr;
}
inline std::string ToNarrow(const std::wstring& wstr) {
std::string str{};
str.resize(std::wcstombs(nullptr, wstr.c_str(), static_cast<uint64_t>(-1)));
std::wcstombs(str.data(), wstr.c_str(), str.size());
return str;
}
template <typename KeyType>
YAML::Node TemplateOverride(const KeyType& key, const YAML::Node& container,
const YAML::Node& templates) {
YAML::Node local = container[key];
YAML::Node use_template = container["use_template"];
if (!local.IsDefined() && use_template.IsDefined() &&
templates[use_template.as<std::string_view>()].IsDefined()) {
return templates[use_template.as<std::string_view>()][key];
}
return local;
}