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