• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "i18n_normalizer.h"
23 
24 namespace OHOS {
25 namespace Global {
26 namespace I18n {
27 class I18nNormalizerAddon {
28 public:
29     I18nNormalizerAddon();
30     ~I18nNormalizerAddon();
31     static void Destructor(napi_env env, void *nativeObject, void *hint);
32     static napi_value InitI18nNormalizer(napi_env env, napi_value exports);
33     static napi_value CreateI18NNormalizerModeEnum(napi_env env, napi_status &initStatus);
34 
35 private:
36     static napi_value I18nNormalizerConstructor(napi_env env, napi_callback_info info);
37 
38     // process js function call
39     static napi_value Normalize(napi_env env, napi_callback_info info);
40 
41     static napi_value GetI18nNormalizerInstance(napi_env env, napi_callback_info info);
42     static napi_status SetEnumValue(napi_env env, napi_value enumObj, const char* enumName, int32_t enumVal);
43 
44     static const int32_t NORMALIZER_MODE_NFC = 1;
45     static const int32_t NORMALIZER_MODE_NFD = 2;
46     static const int32_t NORMALIZER_MODE_NFKC = 3;
47     static const int32_t NORMALIZER_MODE_NFKD = 4;
48     static const char *NORMALIZER_MODE_NFC_NAME;
49     static const char *NORMALIZER_MODE_NFD_NAME;
50     static const char *NORMALIZER_MODE_NFKC_NAME;
51     static const char *NORMALIZER_MODE_NFKD_NAME;
52 
53     std::unique_ptr<I18nNormalizer> normalizer_ = nullptr;
54 };
55 } //namespace I18n
56 } //namespace Global
57 } //namespace OHOS
58 #endif