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>
|
|
|
|
|
2022-03-04 11:36:37 +01:00
|
|
|
#include <hex/helpers/fs.hpp>
|
2022-05-17 20:46:42 +02:00
|
|
|
#include <hex/helpers/file.hpp>
|
2021-02-14 01:11:55 +01:00
|
|
|
|
2022-01-16 01:51:31 +01:00
|
|
|
namespace hex {
|
2021-02-14 01:11:55 +01:00
|
|
|
|
|
|
|
class EncodingFile {
|
|
|
|
public:
|
2022-03-04 11:36:37 +01:00
|
|
|
enum class Type
|
|
|
|
{
|
2022-01-16 01:51:31 +01:00
|
|
|
Thingy
|
2021-02-14 01:11:55 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
EncodingFile() = default;
|
2022-03-04 11:36:37 +01:00
|
|
|
EncodingFile(Type type, const std::fs::path &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
|
|
|
|
2022-01-16 01:51:31 +01:00
|
|
|
[[nodiscard]] bool valid() const { return this->m_valid; }
|
2022-01-15 23:44:15 +01:00
|
|
|
|
2021-02-14 01:11:55 +01:00
|
|
|
private:
|
2022-05-17 20:46:42 +02:00
|
|
|
void parseThingyFile(fs::File &file);
|
2021-02-14 01:11:55 +01:00
|
|
|
|
2022-01-15 23:44:15 +01:00
|
|
|
bool m_valid = false;
|
|
|
|
|
2022-05-17 17:49:14 +02:00
|
|
|
std::map<size_t, std::map<std::vector<u8>, std::string>> m_mapping;
|
2021-02-14 01:11:55 +01:00
|
|
|
size_t m_longestSequence = 0;
|
|
|
|
};
|
|
|
|
|
2022-05-17 17:49:14 +02:00
|
|
|
}
|