35 #ifndef LANGUAGE_BASE_H 36 #define LANGUAGE_BASE_H 39 #include <unordered_map> 41 #include "misc_log_ex.h" 60 size_t avail =
s.size();
61 const char *ptr =
s.data();
62 while (count-- && avail--)
65 while (avail && ((*ptr) & 0xc0) == 0x80)
90 std::unordered_map<epee::wipeable_string, uint32_t>
word_map;
101 std::vector<std::string>::const_iterator it;
103 throw std::runtime_error(
"Wrong word list length for " +
language_name);
112 throw std::runtime_error(
"Too short word in " +
language_name +
" word list: " + *it);
114 epee::wipeable_string trimmed;
126 MWARNING(
"Duplicate prefix in " <<
language_name <<
" word list: " << std::string(trimmed.data(), trimmed.size()));
128 throw std::runtime_error(
"Duplicate prefix in " +
language_name +
" word list: " + std::string(trimmed.data(), trimmed.size()));
147 for (
size_t i = 0; i <
NWORDS; ++i)
162 const std::unordered_map<epee::wipeable_string, uint32_t>&
get_word_map()
const const uint32_t T[512]
Definition: groestl_tables.h:33
Base(const char *language_name, const char *english_language_name, const std::vector< std::string > &words, uint32_t prefix_length)
Definition: language_base.h:134
std::string language_name
Definition: language_base.h:92
std::vector< std::string > word_list
Definition: language_base.h:89
A base language class which all languages have to inherit from for Polymorphism.
Definition: language_base.h:79
Definition: language_base.h:83
void set_words(const char *const words[])
Definition: language_base.h:144
uint32_t get_unique_prefix_length() const
Returns the number of unique starting characters to be used for matching.
Definition: language_base.h:194
Mnemonic language related namespace.
T utf8prefix(const T &s, size_t count)
Returns a string made of (at most) the first count characters in s. Assumes well formedness. No check is made for this.
Definition: language_base.h:57
std::string english_language_name
Definition: language_base.h:93
const std::vector< std::string > & get_word_list() const
Returns a pointer to the word list.
Definition: language_base.h:154
virtual ~Base()
Definition: language_base.h:141
const std::unordered_map< epee::wipeable_string, uint32_t > & get_trimmed_word_map() const
Returns a pointer to the trimmed word map.
Definition: language_base.h:170
const std::string & get_english_language_name() const
Returns the name of the language in English.
Definition: language_base.h:186
std::unordered_map< epee::wipeable_string, uint32_t > trimmed_word_map
Definition: language_base.h:91
Definition: language_base.h:84
void populate_maps(uint32_t flags=0)
Populates the word maps after the list is ready.
Definition: language_base.h:98
Definition: language_base.h:87
const std::string & get_language_name() const
Returns the name of the language.
Definition: language_base.h:178
std::unordered_map< epee::wipeable_string, uint32_t > word_map
Definition: language_base.h:90
const std::unordered_map< epee::wipeable_string, uint32_t > & get_word_map() const
Returns a pointer to the word map.
Definition: language_base.h:162
#define s(x, c)
Definition: aesb.c:46
uint32_t unique_prefix_length
Definition: language_base.h:94