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_STUB_H 17 #define DISTRIBUTED_RDB_RDB_RESULT_SET_STUB_H 18 19 #include <iremote_stub.h> 20 #include "irdb_result_set.h" 21 #include "result_set.h" 22 23 namespace OHOS::DistributedRdb { 24 class RdbResultSetStub : public IRemoteStub<IRdbResultSet> { 25 public: 26 using Code = NativeRdb::RemoteResultSet::Code; 27 explicit RdbResultSetStub(std::shared_ptr<NativeRdb::ResultSet> resultSet); 28 int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; 29 30 private: 31 int32_t OnGetAllColumnNames(MessageParcel &data, MessageParcel &reply); 32 int32_t OnGetColumnCount(MessageParcel &data, MessageParcel &reply); 33 int32_t OnGetColumnType(MessageParcel &data, MessageParcel &reply); 34 int32_t OnGetColumnIndex(MessageParcel &data, MessageParcel &reply); 35 int32_t OnGetColumnName(MessageParcel &data, MessageParcel &reply); 36 int32_t OnGetRowCount(MessageParcel &data, MessageParcel &reply); 37 int32_t OnGetRowIndex(MessageParcel &data, MessageParcel &reply); 38 int32_t OnGoTo(MessageParcel &data, MessageParcel &reply); 39 int32_t OnGoToRow(MessageParcel &data, MessageParcel &reply); 40 int32_t OnGoToFirstRow(MessageParcel &data, MessageParcel &reply); 41 int32_t OnGoToLastRow(MessageParcel &data, MessageParcel &reply); 42 int32_t OnGoToNextRow(MessageParcel &data, MessageParcel &reply); 43 int32_t OnGoToPreviousRow(MessageParcel &data, MessageParcel &reply); 44 int32_t OnIsEnded(MessageParcel &data, MessageParcel &reply); 45 int32_t OnIsStarted(MessageParcel &data, MessageParcel &reply); 46 int32_t OnIsAtFirstRow(MessageParcel &data, MessageParcel &reply); 47 int32_t OnIsAtLastRow(MessageParcel &data, MessageParcel &reply); 48 int32_t OnGetBlob(MessageParcel &data, MessageParcel &reply); 49 int32_t OnGetString(MessageParcel &data, MessageParcel &reply); 50 int32_t OnGetInt(MessageParcel &data, MessageParcel &reply); 51 int32_t OnGetLong(MessageParcel &data, MessageParcel &reply); 52 int32_t OnGetDouble(MessageParcel &data, MessageParcel &reply); 53 int32_t OnIsColumnNull(MessageParcel &data, MessageParcel &reply); 54 int32_t OnIsClosed(MessageParcel &data, MessageParcel &reply); 55 int32_t OnClose(MessageParcel &data, MessageParcel &reply); 56 57 static bool CheckInterfaceToken(MessageParcel &data); 58 using RequestHandle = int (RdbResultSetStub::*)(MessageParcel &, MessageParcel &); 59 static constexpr RequestHandle HANDLERS[Code::CMD_MAX] = { 60 [Code::CMD_GET_ALL_COLUMN_NAMES] = &RdbResultSetStub::OnGetAllColumnNames, 61 [Code::CMD_GET_COLUMN_COUNT] = &RdbResultSetStub::OnGetColumnCount, 62 [Code::CMD_GET_COLUMN_TYPE] = &RdbResultSetStub::OnGetColumnType, 63 [Code::CMD_GET_COLUMN_INDEX] = &RdbResultSetStub::OnGetColumnIndex, 64 [Code::CMD_GET_COLUMN_NAME] = &RdbResultSetStub::OnGetColumnName, 65 [Code::CMD_GET_ROW_COUNT] = &RdbResultSetStub::OnGetRowCount, 66 [Code::CMD_GET_ROW_INDEX] = &RdbResultSetStub::OnGetRowIndex, 67 [Code::CMD_GO_TO] = &RdbResultSetStub::OnGoTo, 68 [Code::CMD_GO_TO_ROW] = &RdbResultSetStub::OnGoToRow, 69 [Code::CMD_GO_TO_FIRST_ROW] = &RdbResultSetStub::OnGoToFirstRow, 70 [Code::CMD_GO_TO_LAST_ROW] = &RdbResultSetStub::OnGoToLastRow, 71 [Code::CMD_GO_TO_NEXT_ROW] = &RdbResultSetStub::OnGoToNextRow, 72 [Code::CMD_GO_TO_PREV_ROW] = &RdbResultSetStub::OnGoToPreviousRow, 73 [Code::CMD_IS_ENDED_ROW] = &RdbResultSetStub::OnIsEnded, 74 [Code::CMD_IS_STARTED_ROW] = &RdbResultSetStub::OnIsStarted, 75 [Code::CMD_IS_AT_FIRST_ROW] = &RdbResultSetStub::OnIsAtFirstRow, 76 [Code::CMD_IS_AT_LAST_ROW] = &RdbResultSetStub::OnIsAtLastRow, 77 [Code::CMD_GET_BLOB] = &RdbResultSetStub::OnGetBlob, 78 [Code::CMD_GET_STRING] = &RdbResultSetStub::OnGetString, 79 [Code::CMD_GET_INT] = &RdbResultSetStub::OnGetInt, 80 [Code::CMD_GET_LONG] = &RdbResultSetStub::OnGetLong, 81 [Code::CMD_GET_DOUBLE] = &RdbResultSetStub::OnGetDouble, 82 [Code::CMD_IS_COLUMN_NULL] = &RdbResultSetStub::OnIsColumnNull, 83 [Code::CMD_IS_CLOSED] = &RdbResultSetStub::OnIsClosed, 84 [Code::CMD_CLOSE] = &RdbResultSetStub::OnClose 85 }; 86 std::shared_ptr<NativeRdb::ResultSet> resultSet_; 87 }; 88 } // namespace OHOS::DistributedRdb 89 #endif // DISTRIBUTED_RDB_RDB_RESULT_SET_STUB_H 90