Open Chinese Convert 1.4.2+g71621a0e1.dirty
A project for conversion between Traditional and Simplified Chinese
Loading...
Searching...
No Matches
opencc::PrefixMatch Class Reference

Classes

struct  Match

Public Member Functions

 PrefixMatch (const DictPtr &dict)
Match MatchPrefix (const char *word, size_t len) const
PrefixMatchView MatchPrefixView (const char *word, size_t len) const
 Like MatchPrefix but returns non-owning string_view fields without copying key or value into thread-local storage.
size_t SkipUnmatchable (const char *word, size_t len) const
 Returns the number of leading bytes of word that are guaranteed not to begin any dictionary key: whole UTF-8 characters whose lead byte starts no key (ideographic description operators excluded, so the caller's IDS grouping is preserved).

Member Function Documentation

◆ MatchPrefixView()

PrefixMatchView opencc::PrefixMatch::MatchPrefixView ( const char * word,
size_t len ) const

Like MatchPrefix but returns non-owning string_view fields without copying key or value into thread-local storage.

Lifetime of the returned views:

  • key: points into the caller's input buffer (fast-path singleDict, where both MarisaDict and DartsDict return a slice of word) or into PrefixMatch-owned table storage (table-path LeafMatcher). Callers must not assume one or the other; copy if the key needs to outlive the current input position.
  • value: valid for the lifetime of the underlying dictionary (fast-path) or the lifetime of this PrefixMatch's tables (table-path).

◆ SkipUnmatchable()

size_t opencc::PrefixMatch::SkipUnmatchable ( const char * word,
size_t len ) const

Returns the number of leading bytes of word that are guaranteed not to begin any dictionary key: whole UTF-8 characters whose lead byte starts no key (ideographic description operators excluded, so the caller's IDS grouping is preserved).

Callers may consume the returned run without calling MatchPrefixView() at any position inside it. The scan is word-at-a-time for ASCII runs. Returns 0 when the next character requires a real lookup.


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