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 16 #ifndef MMS_DECODE_BUFFER_H 17 #define MMS_DECODE_BUFFER_H 18 19 #include <string> 20 21 #include "mms_buffer.h" 22 23 namespace OHOS { 24 namespace Telephony { 25 class MmsDecodeBuffer : public MmsBuffer { 26 public: 27 bool PeekOneByte(uint8_t &oneByte); 28 bool GetOneByte(uint8_t &oneByte); 29 bool IncreasePointer(uint32_t offset); 30 bool DecreasePointer(uint32_t offset); 31 void MarkPosition(); 32 void UnMarkPosition(); 33 34 bool DecodeIsString(); 35 bool DecodeShortLength(uint8_t &sValueLength); 36 bool DecodeValueLengthReturnLen(uint32_t &valueLength, uint32_t &length); 37 bool DecodeValueLength(uint32_t &valueLength); 38 bool DecodeUintvar(uint32_t &uintVar, uint32_t &count); 39 bool DecodeText(std::string &str, uint32_t &len); 40 static bool CharIsToken(uint8_t oneByte); 41 bool DecodeTokenText(std::string &str, uint32_t &len); 42 bool DecodeQuotedText(std::string &str, uint32_t &len); 43 bool DecodeShortInteger(uint8_t &sInteger); 44 bool DecodeIsShortInt(); 45 bool DecodeLongInteger(uint64_t &lInteger); 46 bool DecodeInteger(uint64_t &iInteger); 47 bool DecodeIsValueLength(); 48 49 private: 50 static constexpr uint8_t EDN_S = 0; 51 static constexpr uint8_t NARMAL_TEXT_MIN = 32; 52 static constexpr uint8_t NARMAL_TEXT_MAX = 126; 53 static constexpr uint8_t LONG_VALUE_LEN_MAX = 8; 54 }; 55 } // namespace Telephony 56 } // namespace OHOS 57 #endif 58