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