libime
pinyinmatchstate.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_PINYIN_PINYINMATCHSTATE_H_
7 #define _FCITX_LIBIME_PINYIN_PINYINMATCHSTATE_H_
8 
9 #include <cstddef>
10 #include <memory>
11 #include <unordered_set>
12 #include <fcitx-utils/macros.h>
13 #include <libime/pinyin/libimepinyin_export.h>
14 #include <libime/pinyin/pinyinencoder.h>
15 
16 namespace libime {
17 
18 class PinyinMatchStatePrivate;
19 class SegmentGraphNode;
20 class ShuangpinProfile;
21 class PinyinContext;
22 
23 // Provides caching mechanism used by PinyinContext.
24 class LIBIMEPINYIN_EXPORT PinyinMatchState {
25  friend class PinyinMatchContext;
26 
27 public:
30 
31  // Invalidate everything in the state.
32  void clear();
33 
34  // Invalidate a set of node, usually caused by the change of user input.
35  void discardNode(const std::unordered_set<const SegmentGraphNode *> &node);
36 
37  // Invalidate a whole dictionary, usually caused by the change to the
38  // dictionary.
39  void discardDictionary(size_t idx);
40 
41  PinyinFuzzyFlags fuzzyFlags() const;
42  std::shared_ptr<const ShuangpinProfile> shuangpinProfile() const;
43  std::shared_ptr<const PinyinCorrectionProfile> correctionProfile() const;
44  size_t partialLongWordLimit() const;
45 
46 private:
47  std::unique_ptr<PinyinMatchStatePrivate> d_ptr;
48  FCITX_DECLARE_PRIVATE(PinyinMatchState);
49 };
50 } // namespace libime
51 
52 #endif // _FCITX_LIBIME_PINYIN_PINYINMATCHSTATE_H_