| Index: third_party/hunspell/src/hunspell/hashmgr.hxx
|
| ===================================================================
|
| --- third_party/hunspell/src/hunspell/hashmgr.hxx (revision 50428)
|
| +++ third_party/hunspell/src/hunspell/hashmgr.hxx (working copy)
|
| @@ -8,10 +8,25 @@
|
| #include "htypes.hxx"
|
| #include "filemgr.hxx"
|
|
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| +#include <string>
|
| +#include <map>
|
| +
|
| +#include "base/stl_util-inl.h"
|
| +#include "base/string_piece.h"
|
| +#include "third_party/hunspell/google/bdict_reader.h"
|
| +#endif
|
| +
|
| enum flag { FLAG_CHAR, FLAG_LONG, FLAG_NUM, FLAG_UNI };
|
|
|
| class LIBHUNSPELL_DLL_EXPORTED HashMgr
|
| {
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| + // Not owned by this class, owned by the Hunspell object.
|
| + hunspell::BDictReader* bdict_reader;
|
| + std::map<base::StringPiece, int> custom_word_to_affix_id_map_;
|
| + std::vector<std::string*> pointer_to_strings_;
|
| +#endif
|
| int tablesize;
|
| struct hentry ** tableptr;
|
| int userword;
|
| @@ -34,7 +49,23 @@
|
|
|
|
|
| public:
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| + HashMgr(hunspell::BDictReader* reader);
|
| +
|
| + // Return the hentry corresponding to the given word. Returns NULL if the
|
| + // word is not there in the cache.
|
| + hentry* GetHentryFromHEntryCache(char* word);
|
| +
|
| + // Called before we do a new operation. This will empty the cache of pointers
|
| + // to hentries that we have cached. In Chrome, we make these on-demand, but
|
| + // they must live as long as the single spellcheck operation that they're part
|
| + // of since Hunspell will save pointers to various ones as it works.
|
| + //
|
| + // This function allows that cache to be emptied and not grow infinitely.
|
| + void EmptyHentryCache();
|
| +#else
|
| HashMgr(const char * tpath, const char * apath, const char * key = NULL);
|
| +#endif
|
| ~HashMgr();
|
|
|
| struct hentry * lookup(const char *) const;
|
| @@ -59,6 +90,40 @@
|
| int al, const char * desc, bool onlyupcase);
|
| int load_config(const char * affpath, const char * key);
|
| int parse_aliasf(char * line, FileMgr * af);
|
| +
|
| +#ifdef HUNSPELL_CHROME_CLIENT
|
| + // Loads the AF lines from a BDICT.
|
| + // A BDICT file compresses its AF lines to save memory.
|
| + // This function decompresses each AF line and call parse_aliasf().
|
| + int LoadAFLines();
|
| +
|
| + // Helper functions that create a new hentry struct, initialize it, and
|
| + // delete it.
|
| + // These functions encapsulate non-trivial operations in creating and
|
| + // initializing a hentry struct from BDICT data to avoid changing code so much
|
| + // even when a hentry struct is changed.
|
| + hentry* InitHashEntry(hentry* entry,
|
| + size_t item_size,
|
| + const char* word,
|
| + int word_length,
|
| + int affix_index) const;
|
| + hentry* CreateHashEntry(const char* word,
|
| + int word_length,
|
| + int affix_index) const;
|
| + void DeleteHashEntry(hentry* entry) const;
|
| +
|
| + // Converts the list of affix IDs to a linked list of hentry structures. The
|
| + // hentry structures will point to the given word. The returned pointer will
|
| + // be a statically allocated variable that will change for the next call. The
|
| + // |word| buffer must be the same.
|
| + hentry* AffixIDsToHentry(char* word, int* affix_ids, int affix_count) const;
|
| +
|
| + // See EmptyHentryCache above. Note that each one is actually a linked list
|
| + // followed by the homonym pointer.
|
| + typedef std::map<std::string, hentry*> HEntryCache;
|
| + HEntryCache hentry_cache;
|
| +#endif
|
| +
|
| int add_hidden_capitalized_word(char * word, int wbl, int wcl,
|
| unsigned short * flags, int al, char * dp, int captype);
|
| int parse_aliasm(char * line, FileMgr * af);
|
|
|