1
0
mirror of synced 2024-12-01 02:37:18 +01:00
ImHex/include/helpers/encoding_file.hpp
WerWolv e74c0f5cf5 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
2021-09-08 15:18:24 +02:00

38 lines
876 B
C++

#pragma once
#include <hex.hpp>
#include <map>
#include <string_view>
#include <vector>
namespace hex {
template<typename T>
struct SizeSorter {
bool operator() (const T& lhs, const T& rhs) const {
return lhs.size() < rhs.size();
}
};
class EncodingFile {
public:
enum class Type {
Thingy,
CSV
};
EncodingFile() = default;
EncodingFile(Type type, const std::string &path);
[[nodiscard]] std::pair<std::string_view, size_t> getEncodingFor(const std::vector<u8> &buffer) const;
[[nodiscard]] size_t getLongestSequence() const { return this->m_longestSequence; }
private:
void parseThingyFile(std::ifstream &content);
std::map<u32, std::map<std::vector<u8>, std::string>> m_mapping;
size_t m_longestSequence = 0;
};
}