1 /* 2 * Copyright (C) 2021 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 #ifndef N_NAPI_PASTEBOARD_COMMON_H 16 #define N_NAPI_PASTEBOARD_COMMON_H 17 18 #include <string> 19 20 #include "napi/native_api.h" 21 #include "napi/native_node_api.h" 22 #include "pasteboard_js_err.h" 23 namespace OHOS { 24 namespace MiscServicesNapi { 25 napi_value GetCallbackErrorValue(napi_env env, int32_t errorCode); 26 void SetCallback(const napi_env &env, const napi_ref &callbackIn, const napi_value *result); 27 napi_value NapiGetNull(napi_env env); 28 napi_value CreateNapiNumber(napi_env env, int32_t num); 29 napi_value CreateNapiString(napi_env env, std::string str); 30 bool GetValue(napi_env env, napi_value in, std::string &out); 31 bool CheckArgsType(napi_env env, napi_value in, napi_valuetype expectedType, const char *message); 32 bool CheckExpression(napi_env env, bool expression, MiscServices::JSErrorCode errCode, const char *message); 33 bool CheckArgs(napi_env env, napi_value *argv, size_t argc, std::string &mimeType); 34 } // namespace MiscServicesNapi 35 } // namespace OHOS 36 #endif