1 /* 2 * Copyright (c) 2021-2022 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 FOUNDATION_ACE_INTERFACES_NAPI_KITS_UTILS_H 17 #define FOUNDATION_ACE_INTERFACES_NAPI_KITS_UTILS_H 18 19 #include <chrono> 20 #include <cmath> 21 #include <cstdint> 22 #include <regex> 23 #include <vector> 24 25 #include "native_engine/native_value.h" 26 27 #include "base/i18n/localization.h" 28 #include "base/log/log.h" 29 #include "bridge/common/utils/utils.h" 30 #include "core/common/container.h" 31 32 namespace OHOS::Ace::Napi { 33 34 size_t GetParamLen(napi_value param); 35 36 void NapiThrow(napi_env env, const std::string& message, int32_t errCode); 37 38 bool ParseResourceParam(napi_env env, napi_value value, int32_t& id, int32_t& type, std::vector<std::string>& params); 39 40 bool ParseString(int32_t resId, int32_t type, std::vector<std::string>& params, std::string& result); 41 42 std::string ErrorToMessage(int32_t code); 43 44 } // namespace OHOS::Ace::Napi 45 46 #endif // FOUNDATION_ACE_INTERFACES_NAPI_KITS_UTILS_H 47