1 /* 2 * Copyright (c) 2022 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 RDB_RESULT_SET_BRIDGE_H 17 #define RDB_RESULT_SET_BRIDGE_H 18 19 #include "result_set.h" 20 #include "rdb_errno.h" 21 #include "result_set_bridge.h" 22 #include "string.h" 23 24 namespace OHOS { 25 namespace NativeRdb { 26 class ResultSet; 27 } 28 namespace RdbDataShareAdapter { 29 class API_EXPORT RdbResultSetBridge : public DataShare::ResultSetBridge { 30 public: 31 using ResultSet = NativeRdb::ResultSet; 32 using ColumnType = NativeRdb::ColumnType; 33 34 API_EXPORT RdbResultSetBridge(std::shared_ptr<ResultSet> resultSet); 35 API_EXPORT ~RdbResultSetBridge(); 36 API_EXPORT int GetAllColumnNames(std::vector<std::string> &columnNames) override; 37 API_EXPORT int GetRowCount(int32_t &count) override; 38 API_EXPORT int OnGo(int32_t start, int32_t length, Writer &writer) override; 39 40 private: 41 int32_t WriteBlock(int32_t start, int32_t target, int columnCount, Writer &writer); 42 bool WriteBlobData(int column, Writer &writer); 43 void WriteColumn(int columnCount, Writer &writer, int row); 44 std::shared_ptr<ResultSet> rdbResultSet_; 45 }; 46 } // namespace RdbDataShareAdapter 47 } // namespace OHOS 48 #endif // RDB_RESULT_SET_BRIDGE_H 49