libime
dictionary.h
1 /*
2  * SPDX-FileCopyrightText: 2017-2017 CSSlayer <wengxt@gmail.com>
3  *
4  * SPDX-License-Identifier: LGPL-2.1-or-later
5  */
6 #ifndef _FCITX_LIBIME_CORE_DICTIONARY_H_
7 #define _FCITX_LIBIME_CORE_DICTIONARY_H_
8 
9 #include <functional>
10 #include <memory>
11 #include <unordered_set>
12 #include <libime/core/lattice.h>
13 #include <libime/core/libimecore_export.h>
14 #include <libime/core/segmentgraph.h>
15 
16 namespace libime {
17 
18 class WordNode;
19 
20 // The callback accepts the passed path that matches the word.
21 using GraphMatchCallback =
22  std::function<void(const SegmentGraphPath &, WordNode &, float,
23  std::unique_ptr<LatticeNodeData>)>;
24 
25 class LIBIMECORE_EXPORT Dictionary {
26 public:
27  void
28  matchPrefix(const SegmentGraph &graph, const GraphMatchCallback &callback,
29  const std::unordered_set<const SegmentGraphNode *> &ignore = {},
30  void *helper = nullptr) const;
31 
32 protected:
33  virtual void
34  matchPrefixImpl(const SegmentGraph &graph,
35  const GraphMatchCallback &callback,
36  const std::unordered_set<const SegmentGraphNode *> &ignore,
37  void *helper) const = 0;
38 };
39 } // namespace libime
40 
41 #endif // _FCITX_LIBIME_CORE_DICTIONARY_H_