1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OHOS_GLOBAL_I18N_NORMALIZER_H
17 #define OHOS_GLOBAL_I18N_NORMALIZER_H
18 
19 #include "i18n_normalizer.h"
20 #include "napi/native_api.h"
21 #include "napi/native_node_api.h"
22 
23 namespace OHOS {
24 namespace Global {
25 namespace I18n {
26 class I18nNormalizerAddon {
27 public:
28     I18nNormalizerAddon();
29     ~I18nNormalizerAddon();
30     static void Destructor(napi_env env, void *nativeObject, void *hint);
31     static napi_value InitI18nNormalizer(napi_env env, napi_value exports);
32     static napi_value CreateI18NNormalizerModeEnum(napi_env env, napi_status &initStatus);
33 
34 private:
35     static napi_value I18nNormalizerConstructor(napi_env env, napi_callback_info info);
36     // process js function call
37     static napi_value Normalize(napi_env env, napi_callback_info info);
38     static napi_value InitNormalizer(napi_env env, napi_value exports);
39     static napi_value GetI18nNormalizerInstance(napi_env env, napi_callback_info info);
40     static napi_status SetEnumValue(napi_env env, napi_value enumObj, const char* enumName, int32_t enumVal);
41 
42     static const int32_t NORMALIZER_MODE_NFC = 1;
43     static const int32_t NORMALIZER_MODE_NFD = 2;
44     static const int32_t NORMALIZER_MODE_NFKC = 3;
45     static const int32_t NORMALIZER_MODE_NFKD = 4;
46     static const char *NORMALIZER_MODE_NFC_NAME;
47     static const char *NORMALIZER_MODE_NFD_NAME;
48     static const char *NORMALIZER_MODE_NFKC_NAME;
49     static const char *NORMALIZER_MODE_NFKD_NAME;
50 
51     std::unique_ptr<I18nNormalizer> normalizer_ = nullptr;
52 };
53 } // namespace I18n
54 } // namespace Global
55 } // namespace OHOS
56 #endif