1 /* 2 * Copyright (c) 2024 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 HIAPPEVENT_FRAMEWORKS_JS_NAPI_INCLUDE_NAPI_PARAM_BUILDER_H 16 #define HIAPPEVENT_FRAMEWORKS_JS_NAPI_INCLUDE_NAPI_PARAM_BUILDER_H 17 18 #include <memory> 19 20 #include "napi/native_api.h" 21 #include "napi/native_node_api.h" 22 #include "napi_hiappevent_builder.h" 23 24 namespace OHOS { 25 namespace HiviewDFX { 26 class AppEventPack; 27 28 class NapiParamBuilder : public NapiHiAppEventBuilder { 29 public: NapiParamBuilder()30 NapiParamBuilder() 31 { 32 isV9_ = true; 33 } ~NapiParamBuilder()34 ~NapiParamBuilder() {} 35 std::shared_ptr<AppEventPack> BuildEventParam(const napi_env env, const napi_value params[], size_t len); 36 37 protected: 38 virtual void AddArrayParam2EventPack(napi_env env, const std::string &key, const napi_value arr) override; 39 virtual void AddParams2EventPack(napi_env env, const napi_value paramObj) override; 40 41 private: 42 bool IsValidParams(const napi_env env, const napi_value params[], size_t len); 43 void BuildCustomEventParamPack(napi_env env, const napi_value params[], size_t len); 44 }; 45 } // namespace HiviewDFX 46 } // namespace OHOS 47 #endif // HIAPPEVENT_FRAMEWORKS_JS_NAPI_INCLUDE_NAPI_PARAM_BUILDER_H 48