Debian Codegraph @

modules/pinyinhelper/stroke.h

raw
1 /*
2 * SPDX-FileCopyrightText: 2017-2017 CSSlayer <[email protected]>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-or-later
5 *
6 */
7 #ifndef _PINYINHELPER_STROKE_H_
8 #define _PINYINHELPER_STROKE_H_
9
10 #include <cstdint>
11 #include <future>
12 #include <libime/core/datrie.h>
13 #include <string>
14 #include <unordered_map>
15 #include <utility>
16
17 namespace fcitx {
18
19 class Stroke {
20 public:
21 Stroke();
22
23 void loadAsync();
24 bool load();
25 std::vector<std::pair<std::string, std::string>>
26 lookup(std::string_view input, int limit);
27 std::string prettyString(const std::string &input) const;
28 std::string reverseLookup(const std::string &hanzi) const;
29
30 private:
31 libime::DATrie<int32_t> dict_;
32 libime::DATrie<int32_t> revserseDict_;
33 bool loaded_ = false;
34 bool loadResult_ = false;
35
36 std::future<std::tuple<libime::DATrie<int32_t>, libime::DATrie<int32_t>>>
37 loadFuture_;
38 };
39 } // namespace fcitx
40
41 #endif // _PINYINHELPER_STROKE_H_