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 #include "pasteboard_pattern.h" 24 25 namespace OHOS { 26 namespace MiscServicesNapi { 27 napi_value GetCallbackErrorValue(napi_env env, int32_t errorCode); 28 void SetCallback(const napi_env &env, const napi_ref &callbackIn, const napi_value *result); 29 napi_value NapiGetNull(napi_env env); 30 napi_value CreateNapiNumber(napi_env env, int32_t num); 31 napi_value CreateNapiString(napi_env env, std::string str); 32 bool GetValue(napi_env env, napi_value in, std::string &out); 33 bool GetValue(napi_env env, napi_value in, std::set<MiscServices::Pattern> &out); 34 napi_status SetValue(napi_env env, std::set<MiscServices::Pattern> &in, napi_value &result); 35 bool CheckArgsType(napi_env env, napi_value in, napi_valuetype expectedType, const char *message); 36 bool CheckExpression(napi_env env, bool expression, MiscServices::JSErrorCode errCode, const char *message); 37 bool CheckArgs(napi_env env, napi_value *argv, size_t argc, std::string &mimeType); 38 } // namespace MiscServicesNapi 39 } // namespace OHOS 40 #endif