• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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  INTERFACES_PRIVACY_KITS_NAPI_COMMON_H
17 #define  INTERFACES_PRIVACY_KITS_NAPI_COMMON_H
18 
19 #include "access_token.h"
20 #include "napi/native_api.h"
21 #include "napi/native_node_api.h"
22 
23 namespace OHOS {
24 namespace Security {
25 namespace AccessToken {
26 constexpr int32_t ASYNC_CALL_BACK_VALUES_NUM = 2;
27 constexpr int32_t ASYNC_CALL_BACK_PARAM_ERROR = 0;
28 constexpr int32_t ASYNC_CALL_BACK_PARAM_DATA = 1;
29 
30 bool ParseBool(const napi_env& env, const napi_value& value, bool& result);
31 bool ParseInt32(const napi_env& env, const napi_value& value, int32_t& result);
32 bool ParseInt64(const napi_env& env, const napi_value& value, int64_t& result);
33 bool ParseUint32(const napi_env& env, const napi_value& value, uint32_t& result);
34 bool ParseString(const napi_env& env, const napi_value& value, std::string& result);
35 bool ParseStringArray(const napi_env& env, const napi_value& value, std::vector<std::string>& result);
36 bool ParseAccessTokenIDArray(const napi_env& env, const napi_value& value, std::vector<AccessTokenID>& result);
37 bool ParseCallback(const napi_env& env, const napi_value& value, napi_ref& result);
38 bool IsArray(const napi_env& env, const napi_value& value);
39 bool CheckType(const napi_env& env, const napi_value& value, const napi_valuetype& type);
40 }  // namespace AccessToken
41 }  // namespace Security
42 }  // namespace OHOS
43 #endif /* INTERFACES_PRIVACY_KITS_NAPI_COMMON_H */
44 
45