1 /* 2 * Copyright (c) 2023 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 BASE_EVENT_RAW_DECODE_INCLUDE_RAW_DATA_DECODER_H 17 #define BASE_EVENT_RAW_DECODE_INCLUDE_RAW_DATA_DECODER_H 18 19 #include "base/raw_data_base_def.h" 20 21 namespace OHOS { 22 namespace HiviewDFX { 23 namespace EventRaw { 24 class RawDataDecoder { 25 public: 26 static bool FloatingNumberDecoded(uint8_t* rawData, const size_t maxLen, size_t& pos, double& dest); 27 static bool SignedVarintDecoded(uint8_t* rawData, const size_t maxLen, size_t& pos, int64_t& dest); 28 static bool StringValueDecoded(uint8_t* rawData, const size_t maxLen, size_t& pos, std::string& dest); 29 static bool UnsignedVarintDecoded(uint8_t* rawData, const size_t maxLen, size_t& pos, uint64_t& dest); 30 static bool ValueTypeDecoded(uint8_t* rawData, const size_t maxLen, size_t& pos, struct ParamValueType& dest); 31 32 private: 33 static constexpr int TAG_BYTE_OFFSET = 5; 34 static constexpr int TAG_BYTE_BOUND = (1 << TAG_BYTE_OFFSET); 35 static constexpr int TAG_BYTE_MASK = (TAG_BYTE_BOUND - 1); 36 37 static constexpr int NON_TAG_BYTE_OFFSET = 7; 38 static constexpr int NON_TAG_BYTE_BOUND = (1 << NON_TAG_BYTE_OFFSET); 39 static constexpr int NON_TAG_BYTE_MASK = (NON_TAG_BYTE_BOUND - 1); 40 }; 41 } // namespace EventRaw 42 } // namespace HiviewDFX 43 } // namespace OHOS 44 45 #endif // BASE_EVENT_RAW_DECODE_INCLUDE_RAW_DATA_DECODER_H