1 /* 2 * Copyright (c) 2025 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 HITRACE_CHAIN_ANI_UTIL_H 17 #define HITRACE_CHAIN_ANI_UTIL_H 18 19 #include <ani.h> 20 #include <map> 21 #include <string> 22 #include "hilog/log.h" 23 #include "hilog/log_cpp.h" 24 25 namespace OHOS { 26 namespace HiviewDFX { 27 28 class HiTraceChainAniUtil { 29 public: 30 static bool IsRefUndefined(ani_env* env, ani_ref ref); 31 static ani_status ParseStringValue(ani_env* env, ani_ref aniStrRef, std::string& name); 32 static int64_t ParseNumberValueInt64(ani_env* env, ani_ref elementRef); 33 static int32_t ParseNumberValueInt32(ani_env* env, ani_ref elementRef); 34 static uint64_t ParseBigIntValue(ani_env* env, ani_ref elementRef); 35 static ani_status EnumGetValueInt32(ani_env* env, ani_enum_item enumItem, int32_t& value); 36 static ani_object CreateBigInt(ani_env* env, uint64_t traceId); 37 static ani_object CreateDoubleUint64(ani_env* env, uint64_t number); 38 static ani_object CreateDoubleInt(ani_env* env, int number); 39 }; 40 } // namespace HiviewDFX 41 } // namespace OHOS 42 43 #endif // HITRACE_CHAIN_ANI_UTIL_H 44