2021-02-14 01:11:55 +01:00
# pragma once
# include <hex.hpp>
2022-05-28 16:18:55 +02:00
// TODO: Workaround for weird issue picked up by GCC 12.1.0 and later. This seems like a compiler bug mentioned in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98465
# pragma GCC diagnostic push
2022-05-28 19:59:38 +02:00
# if (__GNUC__ >= 12)
# pragma GCC diagnostic ignored "-Wrestrict"
# pragma GCC diagnostic ignored "-Wstringop-overread"
# endif
# include <map>
# include <string_view>
# include <vector>
2022-05-28 16:18:55 +02:00
# pragma GCC diagnostic pop
2021-02-14 01:11:55 +01:00
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
}