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 DISTRIBUTED_RDB_RDB_RESULT_SET_IMPL_H 17 #define DISTRIBUTED_RDB_RDB_RESULT_SET_IMPL_H 18 19 #include <shared_mutex> 20 #include "rdb_result_set_stub.h" 21 #include "distributeddb/result_set.h" 22 23 namespace OHOS::DistributedRdb { 24 class RdbResultSetImpl final : public RdbResultSetStub { 25 public: 26 using DbColumnType = DistributedDB::ResultSet::ColumnType; 27 explicit RdbResultSetImpl(std::shared_ptr<DistributedDB::ResultSet> &resultSet); ~RdbResultSetImpl()28 ~RdbResultSetImpl() override {}; 29 int GetAllColumnNames(std::vector<std::string> &columnNames) override; 30 int GetColumnCount(int &count) override; 31 int GetColumnType(int columnIndex, ColumnType &columnType) override; 32 int GetColumnIndex(const std::string &columnName, int &columnIndex) override; 33 int GetColumnName(int columnIndex, std::string &columnName) override; 34 int GetRowCount(int &count) override; 35 int GetRowIndex(int &position) const override; 36 int GoTo(int offset) override; 37 int GoToRow(int position) override; 38 int GoToFirstRow() override; 39 int GoToLastRow() override; 40 int GoToNextRow() override; 41 int GoToPreviousRow() override; 42 int IsEnded(bool &result) override; 43 int IsStarted(bool &result) const override; 44 int IsAtFirstRow(bool &result) const override; 45 int IsAtLastRow(bool &result) override; 46 int GetBlob(int columnIndex, std::vector<uint8_t> &blob) override; 47 int GetString(int columnIndex, std::string &value) override; 48 int GetInt(int columnIndex, int &value) override; 49 int GetLong(int columnIndex, int64_t &value) override; 50 int GetDouble(int columnIndex, double &value) override; 51 int IsColumnNull(int columnIndex, bool &isNull) override; 52 bool IsClosed() const override; 53 int Close() override; 54 55 private: 56 mutable std::shared_mutex mutex_ {}; 57 std::shared_ptr<DistributedDB::ResultSet> resultSet_; 58 ColumnType ConvertColumnType(DbColumnType columnType) const; 59 }; 60 } // namespace OHOS::DistributedRdb 61 #endif // DISTRIBUTED_RDB_RDB_RESULT_SET_IMPL_H 62