• 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 OHOS_TAG_SERVICE_H
17 #define OHOS_TAG_SERVICE_H
18 
19 #include <charconv>
20 #include <cinttypes>
21 #include <iostream>
22 #include <iomanip>
23 #include <sstream>
24 #include <string>
25 #include <vector>
26 
27 #include "sim_constant.h"
28 #include "sim_utils.h"
29 
30 namespace OHOS {
31 namespace Telephony {
32 class TagService {
33 public:
34     explicit TagService(const std::string &data);
35     explicit TagService(const std::vector<uint8_t> &data);
36     virtual ~TagService();
37     bool Next();
38     int GetTagCode() const;
39     void GetValue(std::vector<uint8_t> &result) const;
40     uint8_t GetLength() const;
41     constexpr static uint8_t HEX_TYPE = 16;
42     constexpr static int32_t ERR = -1;
43 
44 private:
45     uint8_t length_ = 0;
46     std::string tag_;
47     size_t offset_ = 0;
48     std::vector<uint8_t> data_;
49     size_t dataOffset_ = 0;
50     bool hasNext_ = true;
51     constexpr static uint8_t CHINESE_FLAG = 0x80;
52     constexpr static uint8_t UCS_FLAG = 0x81;
53     constexpr static uint8_t CHINESE_POS = 2;
54     constexpr static uint8_t UCS_POS = 3;
55     constexpr static uint8_t CUR_OFFSET = 1;
56 };
57 } // namespace Telephony
58 } // namespace OHOS
59 #endif // OHOS_TAG_SERVICE_H