sys: Tons of long overdue cleanup

- std::string -> const std::string& where needed
- Added a FileIO abstraction class
- Fixed recent files not updating
- Removed localization file from global include
- Renamed lang to pattern_language/pl
- Renamed EventFileDropped to RequestFileOpen
This commit is contained in:
WerWolv
2021-09-08 15:18:24 +02:00
parent d7707bae62
commit e74c0f5cf5
74 changed files with 549 additions and 494 deletions

View File

@@ -1,13 +1,14 @@
#include "helpers/encoding_file.hpp"
#include <ranges>
#include <hex/helpers/utils.hpp>
#include <fstream>
namespace hex {
EncodingFile::EncodingFile(Type type, std::string_view path) {
std::ifstream encodingFile(path.data());
EncodingFile::EncodingFile(Type type, const std::string &path) {
std::ifstream encodingFile(path.c_str());
switch (type) {
case Type::Thingy: parseThingyFile(encodingFile); break;
@@ -16,9 +17,7 @@ namespace hex {
}
std::pair<std::string_view, size_t> EncodingFile::getEncodingFor(const std::vector<u8> &buffer) const {
for (auto iter = this->m_mapping.rbegin(); iter != this->m_mapping.rend(); iter++) {
auto &[size, mapping] = *iter;
for (const auto &[size, mapping] : this->m_mapping | std::views::reverse) {
if (size > buffer.size()) continue;
auto key = std::vector<u8>(buffer.begin(), buffer.begin() + size);