enum flag { FLAG_CHAR, FLAG_LONG, FLAG_NUM, FLAG_UNI };
// morphological description of a dictionary item can contain // arbitrary number "ph:" (MORPH_PHON) fields to store typical // phonetic or other misspellings of that word. // ratio of lines/lines with "ph:" in the dic file: 1/MORPH_PHON_RATIO #define MORPH_PHON_RATIO 500
class HashMgr {
std::vector<struct hentry*> tableptr;
flag flag_mode; int complexprefixes; int utf8; unsignedshort forbiddenword; int langnum;
std::string enc;
std::string lang; conststruct cs_info* csconv;
std::string ignorechars;
std::vector<w_char> ignorechars_utf16;
std::vector<unsignedshort*> aliasf; // flag vector `compression' with aliases
std::vector<unsignedshort> aliasflen;
std::vector<char*> aliasm; // morphological desciption `compression' with aliases // reptable created from REP table of aff file and from "ph:" fields // of the dic file. It contains phonetic and other common misspellings // (letters, letter groups and words) for better suggestions
std::vector<replentry> reptable;
struct hentry* lookup(constchar* word, size_t len) const; int hash(constchar* word, size_t len) const; struct hentry* walk_hashtable(int& col, struct hentry* hp) const;
int add(const std::string& word); int add_with_flags(const std::string& word, const std::string& flags, const std::string& desc = ""); int add_with_affix(const std::string& word, const std::string& pattern); int remove(const std::string& word); int decode_flags(unsignedshort** result, const std::string& flags, FileMgr* af) const; bool decode_flags(std::vector<unsignedshort>& result, const std::string& flags, FileMgr* af) const; unsignedshort decode_flag(const std::string& flag) const;
std::string encode_flag(unsignedshort flag) const; int is_aliasf() const; int get_aliasf(int index, unsignedshort** fvec, FileMgr* af) const; int is_aliasm() const; char* get_aliasm(int index) const; const std::vector<replentry>& get_reptable() const;
private: int get_clen_and_captype(const std::string& word, int* captype); int get_clen_and_captype(const std::string& word, int* captype, std::vector<w_char> &workbuf); int load_tables(constchar* tpath, constchar* key); int add_word(const std::string& word, int wcl, unsignedshort* ap, int al, const std::string* desc, bool onlyupcase, int captype, bool own_aff); int load_config(constchar* affpath, constchar* key); bool parse_aliasf(const std::string& line, FileMgr* af); int add_hidden_capitalized_word(const std::string& word, int wcl, unsignedshort* flags, int al, const std::string* dp, int captype); bool parse_aliasm(const std::string& line, FileMgr* af); bool parse_reptable(const std::string& line, FileMgr* af); void remove_forbidden_flag(const std::string& word); void free_table(); void release_flags(unsignedshort* astr, bool owned);
// Only internal consumers are allowed to arena-allocate. int decode_flags(unsignedshort** result, const std::string& flags, FileMgr* af, booluse_arena) const;
// Our Mozilla fork uses a simple arena allocator for strings and hentry structs // which persist for the lifetime of the HashMgr, to avoid heap fragmentation. // It's a bump-allocator. arena_free does not release memory (the arena // vector frees everything in bulk at HashMgr destruction); it only updates // a counter and aborts on underflow as a memory-safety check. // Declared const (with arena members mutable) because decode_flags is // part of the public const API and calls this internally. void* arena_alloc(size_t num_bytes, size_t alignment) const; void arena_free(void* ptr) const;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.