25#include "DictEntry.hpp"
32enum class DictGroupMatchPolicy {
56 std::string_view value;
69 size_t len)
const = 0;
75 return Match(word.c_str(), word.length());
105 virtual std::vector<const DictEntry*> MatchAllPrefixes(
const char* word,
111 std::vector<const DictEntry*>
139 return DictGroupMatchPolicy::ShortCircuit;
159 virtual ~Dict() =
default;
Abstract class of dictionary.
Definition Dict.hpp:63
virtual bool SupportsFastPrefixMatch() const
Returns true if this dict can handle prefix queries directly without PrefixMatch building a lookup ta...
Definition Dict.hpp:147
virtual PrefixMatchView MatchPrefixValue(const char *word, size_t len) const
Fast-path prefix match.
Definition Dict.hpp:154
virtual size_t KeyMaxLength() const =0
Returns the length of the longest key in the dictionary.
virtual Optional< const DictEntry * > Match(const char *word, size_t len) const =0
Matches a word exactly and returns the DictEntry or Optional::Null().
virtual LexiconPtr GetLexicon() const =0
Returns all entries in the dictionary.
Optional< const DictEntry * > MatchPrefix(const std::string &word) const
Matches the longest matched prefix of a word.
Definition Dict.hpp:96
Optional< const DictEntry * > Match(const std::string &word) const
Matches a word exactly and returns the DictEntry or Optional::Null().
Definition Dict.hpp:74
Optional< const DictEntry * > MatchPrefix(const char *word) const
Matches the longest matched prefix of a word.
Definition Dict.hpp:89
virtual DictGroupMatchPolicy GetMatchPolicy() const
Returns the match policy when this dictionary is a group.
Definition Dict.hpp:138
virtual const std::list< DictPtr > * GetDictGroupItems() const
Returns child dictionaries when this dictionary is a group.
Definition Dict.hpp:129
virtual Optional< const DictEntry * > MatchPrefix(const char *word, size_t len) const
Matches the longest matched prefix of a word.
Definition Dict.cpp:25
virtual std::vector< const DictEntry * > MatchAllPrefixes(const char *word, size_t len) const
Returns all matched prefixes of a word, sorted by the length (desc).
Definition Dict.cpp:42
std::vector< const DictEntry * > MatchAllPrefixes(const std::string &word) const
Returns all matched prefixes of a word, sorted by the length (desc).
Definition Dict.hpp:112
A class that wraps type T into a nullable type.
Definition Optional.hpp:26
Result of a PrefixMatch fast-path lookup.
Definition Dict.hpp:52