Fcitx
optiontypename.h
1 /*
2  * SPDX-FileCopyrightText: 2015-2015 CSSlayer <wengxt@gmail.com>
3  *
4  * SPDX-License-Identifier: LGPL-2.1-or-later
5  *
6  */
7 #ifndef _FCITX_CONFIG_TYPENAME_H_
8 #define _FCITX_CONFIG_TYPENAME_H_
9 
10 #include <string>
11 #include <type_traits>
12 #include <vector>
13 #include <fcitx-utils/color.h>
14 #include <fcitx-utils/i18nstring.h>
15 #include <fcitx-utils/key.h>
16 #include <fcitx-utils/macros.h>
17 #include <fcitx-utils/semver.h>
18 
19 namespace fcitx {
20 
21 #define FCITX_SPECIALIZE_TYPENAME(TYPE, NAME) \
22  static inline std::string _FCITX_UNUSED_ configTypeNameHelper(TYPE *) { \
23  return NAME; \
24  }
25 
26 FCITX_SPECIALIZE_TYPENAME(bool, "Boolean");
27 FCITX_SPECIALIZE_TYPENAME(int, "Integer");
28 FCITX_SPECIALIZE_TYPENAME(std::string, "String");
29 FCITX_SPECIALIZE_TYPENAME(SemanticVersion, "Version");
30 FCITX_SPECIALIZE_TYPENAME(fcitx::Key, "Key");
31 FCITX_SPECIALIZE_TYPENAME(fcitx::Color, "Color");
32 FCITX_SPECIALIZE_TYPENAME(fcitx::I18NString, "I18NString");
33 
34 template <typename T, typename = void>
36  static std::string get() {
37  using ::fcitx::configTypeNameHelper;
38  return configTypeNameHelper(static_cast<T *>(nullptr));
39  }
40 };
41 
42 template <typename T>
43 struct OptionTypeName<std::vector<T>> {
44  static std::string get() { return "List|" + OptionTypeName<T>::get(); }
45 };
46 
47 template <typename T>
48 struct OptionTypeName<T, std::enable_if_t<std::is_enum_v<T>>> {
49  static std::string get() { return "Enum"; }
50 };
51 } // namespace fcitx
52 
53 #endif // _FCITX_CONFIG_TYPENAME_H_
Describe a Key in fcitx.
Definition: key.h:41
Definition: action.cpp:17
Definition: matchrule.h:78
Color class for handling color.
Definition: color.h:28
Simple color class that represent a 64bit color.
Class to represent a key.