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:
31
betterRenderer/mashadercompiler/src/utils.hpp
Normal file
31
betterRenderer/mashadercompiler/src/utils.hpp
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user