7 #ifndef _FCITX_UTILS_METASTRING_H_ 8 #define _FCITX_UTILS_METASTRING_H_ 22 using array_type =
char const (&)[
sizeof...(c) + 1];
24 static constexpr std::size_t size() {
return size_; }
25 static constexpr
const char *data() {
return str_; }
26 static constexpr
bool empty() {
return size_ == 0; }
28 static constexpr array_type str() {
return str_; }
31 static constexpr
const char str_[
sizeof...(c) + 1] = {c...,
'\0'};
32 static const std::size_t size_ =
sizeof...(c);
35 template <
int N,
int M>
36 constexpr
char __getChar(
char const (&str)[M]) noexcept {
37 if constexpr (N < M) {
43 template <
typename... T>
56 template <
char... c,
typename... Rem>
60 template <
char... c,
char c2,
typename... Rem>
65 template <
typename...>
78 template <
char... c1s,
char... c2s,
typename... _Rem>
84 template <
typename... Args>
92 template <
char first,
char... next>
95 ConcatMetaStringType<MetaString<first>,
96 RemoveMetaStringTailType<
MetaString<next...>>>;
103 template <
typename... T>
106 template <
typename... T>
107 using MetaStringBasenameHelperType =
122 using type = MetaStringBasenameHelperType<
MetaString<c...>>;
125 template <
char... c,
char c2,
typename... Rem>
127 using type = MetaStringBasenameHelperType<
MetaString<c..., c2>, Rem...>;
130 template <
char... c,
typename... Rem>
132 using type = MetaStringBasenameHelperType<Rem...>;
135 template <
typename T>
140 using type = MetaStringBasenameHelperType<MetaString<c>...>;
143 template <
typename T>
154 #define FCITX_METASTRING_TEMPLATE_16(N, S) \ 155 ::fcitx::__getChar<0x##N##0>(S), ::fcitx::__getChar<0x##N##1>(S), \ 156 ::fcitx::__getChar<0x##N##2>(S), ::fcitx::__getChar<0x##N##3>(S), \ 157 ::fcitx::__getChar<0x##N##4>(S), ::fcitx::__getChar<0x##N##5>(S), \ 158 ::fcitx::__getChar<0x##N##6>(S), ::fcitx::__getChar<0x##N##7>(S), \ 159 ::fcitx::__getChar<0x##N##8>(S), ::fcitx::__getChar<0x##N##9>(S), \ 160 ::fcitx::__getChar<0x##N##A>(S), ::fcitx::__getChar<0x##N##B>(S), \ 161 ::fcitx::__getChar<0x##N##C>(S), ::fcitx::__getChar<0x##N##D>(S), \ 162 ::fcitx::__getChar<0x##N##E>(S), ::fcitx::__getChar<0x##N##F>(S) 164 #define FCITX_METASTRING_TEMPLATE_256(N, S) \ 165 FCITX_METASTRING_TEMPLATE_16(N##0, S) \ 166 , FCITX_METASTRING_TEMPLATE_16(N##1, S), \ 167 FCITX_METASTRING_TEMPLATE_16(N##2, S), \ 168 FCITX_METASTRING_TEMPLATE_16(N##3, S), \ 169 FCITX_METASTRING_TEMPLATE_16(N##4, S), \ 170 FCITX_METASTRING_TEMPLATE_16(N##5, S), \ 171 FCITX_METASTRING_TEMPLATE_16(N##6, S), \ 172 FCITX_METASTRING_TEMPLATE_16(N##7, S), \ 173 FCITX_METASTRING_TEMPLATE_16(N##8, S), \ 174 FCITX_METASTRING_TEMPLATE_16(N##9, S), \ 175 FCITX_METASTRING_TEMPLATE_16(N##A, S), \ 176 FCITX_METASTRING_TEMPLATE_16(N##B, S), \ 177 FCITX_METASTRING_TEMPLATE_16(N##C, S), \ 178 FCITX_METASTRING_TEMPLATE_16(N##D, S), \ 179 FCITX_METASTRING_TEMPLATE_16(N##E, S), \ 180 FCITX_METASTRING_TEMPLATE_16(N##F, S) 183 #define fcitxMakeMetaString(STRING) \ 184 ::fcitx::MetaStringTrimType<FCITX_METASTRING_TEMPLATE_256(, STRING)> 187 #endif // _FCITX_UTILS_METASTRING_H_