Loading...
Searching...
No Matches
opencc::Dict Class Referenceabstract
OpenCC C++ Comprehensive API

Abstract class of dictionary. More...

`#include <src/Dict.hpp>`

Inheritance diagram for opencc::Dict:

## Public Member Functions

virtual Optional< const DictEntry * > | Match (const char *word, size_t len) const =0
| Matches a word exactly and returns the DictEntry or Optional::Null().
Optional< const DictEntry * > | Match (const std::string &word) const
| Matches a word exactly and returns the DictEntry or Optional::Null().
virtual Optional< const DictEntry * > | MatchPrefix (const char *word, size_t len) const
| Matches the longest matched prefix of a word.
Optional< const DictEntry * > | MatchPrefix (const char *word) const
| Matches the longest matched prefix of a word.
Optional< const DictEntry * > | MatchPrefix (const std::string &word) const
| Matches the longest matched prefix of a word.
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).
std::vector< const DictEntry * > | MatchAllPrefixes (const std::string &word) const
| Returns all matched prefixes of a word, sorted by the length (desc).
virtual size_t | KeyMaxLength () const =0
| Returns the length of the longest key in the dictionary.
virtual LexiconPtr | GetLexicon () const =0
| Returns all entries in the dictionary.
virtual const std::list< DictPtr > * | GetDictGroupItems () const
| Returns child dictionaries when this dictionary is a group.
virtual DictGroupMatchPolicy | GetMatchPolicy () const
| Returns the match policy when this dictionary is a group.
virtual bool | SupportsFastPrefixMatch () const
| Returns true if this dict can handle prefix queries directly without PrefixMatch building a lookup table.
virtual PrefixMatchView | MatchPrefixValue (const char *word, size_t len) const
| Fast-path prefix match.

## Detailed Description

Abstract class of dictionary.

## Member Function Documentation

## GetDictGroupItems()

virtual const std::list< DictPtr > * opencc::Dict::GetDictGroupItems | ( |  | ) | const

inline virtual

Returns child dictionaries when this dictionary is a group.

Reimplemented in opencc::DictGroup.

## GetLexicon()

virtual LexiconPtr opencc::Dict::GetLexicon | ( |  | ) | const

pure virtual

Returns all entries in the dictionary.

Implemented in opencc::DartsDict, opencc::DictGroup, opencc::MarisaDict, and opencc::TextDict.

## GetMatchPolicy()

virtual DictGroupMatchPolicy opencc::Dict::GetMatchPolicy | ( |  | ) | const

inline virtual

Returns the match policy when this dictionary is a group.

Non-group dictionaries return ShortCircuit because the value is ignored unless GetDictGroupItems() returns children.

Reimplemented in opencc::DictGroup.

## KeyMaxLength()

virtual size_t opencc::Dict::KeyMaxLength | ( |  | ) | const

pure virtual

Returns the length of the longest key in the dictionary.

Implemented in opencc::DartsDict, opencc::DictGroup, opencc::MarisaDict, and opencc::TextDict.

## Match()

virtual Optional< const DictEntry * > opencc::Dict::Match | ( | const char * | word,
|  | size_t | len ) const

pure virtual

Matches a word exactly and returns the DictEntry or Optional::Null().

Implemented in opencc::DartsDict, opencc::DictGroup, opencc::MarisaDict, and opencc::TextDict.

## MatchAllPrefixes()

std::vector< const DictEntry * > Dict::MatchAllPrefixes | ( | const char * | word,
|  | size_t | len ) const

virtual

Returns all matched prefixes of a word, sorted by the length (desc).

For example given a dictionary having "a", "an", "b", "ba", "ban", "bana", all the matched prefixes of "banana" are "bana", "ban", "ba", "b".

Reimplemented in opencc::DictGroup, and opencc::MarisaDict.

## MatchPrefix()

Optional< const DictEntry * > Dict::MatchPrefix | ( | const char * | word,
|  | size_t | len ) const

virtual

Matches the longest matched prefix of a word.

For example given a dictionary having "a", "an", "b", "ba", "ban", "bana", the longest prefix of "banana" matched is "bana".

Reimplemented in opencc::DartsDict, opencc::DictGroup, opencc::MarisaDict, and opencc::UnionDictGroup.

## MatchPrefixValue()

virtual PrefixMatchView opencc::Dict::MatchPrefixValue | ( | const char * | word,
|  | size_t | len ) const

inline virtual

Fast-path prefix match.

Only called when SupportsFastPrefixMatch() is true. Returns a PrefixMatchView with matched=false on no match. See PrefixMatch::MatchPrefixView() for key/value lifetime details.

Reimplemented in opencc::DartsDict, and opencc::MarisaDict.

## SupportsFastPrefixMatch()

virtual bool opencc::Dict::SupportsFastPrefixMatch | ( |  | ) | const

inline virtual

Returns true if this dict can handle prefix queries directly without PrefixMatch building a lookup table.

Subclasses that override MatchPrefixValue() must also override this to return true.

Reimplemented in opencc::DartsDict, and opencc::MarisaDict.

The documentation for this class was generated from the following files:

- Dict.hpp
- Dict.cpp