2021-02-14 01:11:55 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <hex.hpp>
|
|
|
|
|
|
|
|
#include <map>
|
2021-09-08 15:18:24 +02:00
|
|
|
#include <string_view>
|
2021-02-14 01:11:55 +01:00
|
|
|
#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;
|
2021-09-08 15:18:24 +02:00
|
|
|
EncodingFile(Type type, const std::string &path);
|
2021-02-14 01:11:55 +01:00
|
|
|
|
2021-09-08 15:18:24 +02:00
|
|
|
[[nodiscard]] std::pair<std::string_view, size_t> getEncodingFor(const std::vector<u8> &buffer) const;
|
|
|
|
[[nodiscard]] size_t getLongestSequence() const { return this->m_longestSequence; }
|
2021-02-14 01:11:55 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
void parseThingyFile(std::ifstream &content);
|
|
|
|
|
|
|
|
std::map<u32, std::map<std::vector<u8>, std::string>> m_mapping;
|
|
|
|
size_t m_longestSequence = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|