1 /* 2 * Copyright (C) 2025 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 PDP_RESULT_SET_BRIDGE_H 17 #define PDP_RESULT_SET_BRIDGE_H 18 19 #include <condition_variable> 20 #include <mutex> 21 #include <functional> 22 #include <cstddef> 23 #include <cstdint> 24 25 #include "kvstore_result_set.h" 26 #include "result_set_bridge.h" 27 #include "pdp_profile_data.h" 28 29 namespace OHOS { 30 namespace Telephony { 31 using NativeData = std::variant<std::monostate, int64_t, double_t, std::string, std::vector<uint8_t>>; 32 using NativeRecord = std::vector<NativeData>; 33 struct NativeDataSet { 34 std::vector<std::string> columnNames; 35 std::vector<NativeRecord> records; 36 }; 37 38 class PdpResultSetBridge : public DataShare::ResultSetBridge { 39 public: 40 using WriteFunc = std::function<int(Writer &, const NativeRecord &record, uint32_t)>; 41 struct ColumnDefinition { 42 std::string name; 43 WriteFunc write; 44 }; 45 PdpResultSetBridge(const NativeDataSet &dataSet); 46 ~PdpResultSetBridge() = default; 47 int GetRowCount(int32_t &count) override; 48 int GetAllColumnNames(std::vector<std::string> &columnNames) override; 49 int OnGo(int32_t startRowIndex, int32_t targetRowIndex, DataShare::ResultSetBridge::Writer &writer) override; 50 int FillBlocks(int32_t startRowIndex, int32_t targetRowIndex, DataShare::ResultSetBridge::Writer &Writer); 51 52 private: 53 std::vector<NativeRecord> data_; 54 uint32_t count_ = 0; 55 std::vector<std::string> columnsNames_; 56 }; 57 } // namespace Telephony 58 } // namespace OHOS 59 #endif // PDP_RESULT_SET_BRIDGE_H