2021-02-14 01:11:55 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <hex.hpp>
|
|
|
|
|
2022-08-05 08:42:09 +02:00
|
|
|
#include <map>
|
|
|
|
#include <string_view>
|
|
|
|
#include <vector>
|
2023-01-28 21:12:35 +01:00
|
|
|
#include <span>
|
2021-02-14 01:11:55 +01:00
|
|
|
|
2023-03-12 18:27:29 +01:00
|
|
|
#include <wolv/io/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
|
|
|
};
|
|
|
|
|
2023-06-21 23:58:21 +02:00
|
|
|
EncodingFile();
|
|
|
|
EncodingFile(const EncodingFile &other);
|
2023-11-10 20:47:08 +01:00
|
|
|
EncodingFile(EncodingFile &&other) noexcept;
|
2022-03-04 11:36:37 +01:00
|
|
|
EncodingFile(Type type, const std::fs::path &path);
|
2023-11-10 20:47:08 +01:00
|
|
|
EncodingFile(Type type, const std::string &content);
|
2021-02-14 01:11:55 +01:00
|
|
|
|
2023-06-21 23:58:21 +02:00
|
|
|
EncodingFile& operator=(const EncodingFile &other);
|
2023-11-10 20:47:08 +01:00
|
|
|
EncodingFile& operator=(EncodingFile &&other) noexcept;
|
2023-06-21 23:58:21 +02:00
|
|
|
|
2023-01-28 21:12:35 +01:00
|
|
|
[[nodiscard]] std::pair<std::string_view, size_t> getEncodingFor(std::span<u8> buffer) const;
|
2023-03-14 09:35:43 +01:00
|
|
|
[[nodiscard]] size_t getEncodingLengthFor(std::span<u8> buffer) const;
|
2021-09-08 15:18:24 +02:00
|
|
|
[[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
|
|
|
|
2023-03-31 11:06:51 +02:00
|
|
|
[[nodiscard]] const std::string& getTableContent() const { return this->m_tableContent; }
|
|
|
|
|
2023-07-11 00:04:26 +02:00
|
|
|
[[nodiscard]] const std::string& getName() const { return this->m_name; }
|
|
|
|
|
2021-02-14 01:11:55 +01:00
|
|
|
private:
|
2023-03-31 11:06:51 +02:00
|
|
|
void parse(const std::string &content);
|
2021-02-14 01:11:55 +01:00
|
|
|
|
2022-01-15 23:44:15 +01:00
|
|
|
bool m_valid = false;
|
|
|
|
|
2023-07-11 00:04:26 +02:00
|
|
|
std::string m_name;
|
2023-03-31 11:06:51 +02:00
|
|
|
std::string m_tableContent;
|
2023-06-21 23:58:21 +02:00
|
|
|
std::unique_ptr<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
|
|
|
}
|