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