• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
21 #include "irdb_result_set.h"
22 #include "result_set.h"
23 #include "rdb_result_set_impl.h"
24 
25 namespace OHOS::DistributedRdb {
26 class RdbResultSetStub : public IRemoteStub<IRdbResultSet> {
27 public:
28     using Code = NativeRdb::RemoteResultSet::Code;
29     explicit RdbResultSetStub(std::shared_ptr<NativeRdb::ResultSet> resultSet);
30     int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
31 
32 private:
33     int32_t OnGetAllColumnNames(MessageParcel &data, MessageParcel &reply);
34     int32_t OnGetColumnCount(MessageParcel &data, MessageParcel &reply);
35     int32_t OnGetColumnType(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 OnGet(MessageParcel &data, MessageParcel &reply);
49     int32_t OnGetSize(MessageParcel &data, MessageParcel &reply);
50     int32_t OnClose(MessageParcel &data, MessageParcel &reply);
51 
52     static bool CheckInterfaceToken(MessageParcel &data);
53     using RequestHandle = int (RdbResultSetStub::*)(MessageParcel &, MessageParcel &);
54 RDB_UTILS_PUSH_WARNING
55 RDB_UTILS_DISABLE_WARNING("-Wc99-designator")
56     static constexpr RequestHandle HANDLERS[Code::CMD_MAX] = {
57         [Code::CMD_GET_ALL_COLUMN_NAMES] = &RdbResultSetStub::OnGetAllColumnNames,
58         [Code::CMD_GET_COLUMN_COUNT] = &RdbResultSetStub::OnGetColumnCount,
59         [Code::CMD_GET_COLUMN_TYPE] = &RdbResultSetStub::OnGetColumnType,
60         [Code::CMD_GET_ROW_COUNT] = &RdbResultSetStub::OnGetRowCount,
61         [Code::CMD_GET_ROW_INDEX] = &RdbResultSetStub::OnGetRowIndex,
62         [Code::CMD_GO_TO] = &RdbResultSetStub::OnGoTo,
63         [Code::CMD_GO_TO_ROW] = &RdbResultSetStub::OnGoToRow,
64         [Code::CMD_GO_TO_FIRST_ROW] = &RdbResultSetStub::OnGoToFirstRow,
65         [Code::CMD_GO_TO_LAST_ROW] = &RdbResultSetStub::OnGoToLastRow,
66         [Code::CMD_GO_TO_NEXT_ROW] = &RdbResultSetStub::OnGoToNextRow,
67         [Code::CMD_GO_TO_PREV_ROW] = &RdbResultSetStub::OnGoToPreviousRow,
68         [Code::CMD_IS_ENDED_ROW] = &RdbResultSetStub::OnIsEnded,
69         [Code::CMD_IS_STARTED_ROW] = &RdbResultSetStub::OnIsStarted,
70         [Code::CMD_IS_AT_FIRST_ROW] = &RdbResultSetStub::OnIsAtFirstRow,
71         [Code::CMD_IS_AT_LAST_ROW] = &RdbResultSetStub::OnIsAtLastRow,
72         [Code::CMD_GET] = &RdbResultSetStub::OnGet,
73         [Code::CMD_GET_SIZE] = &RdbResultSetStub::OnGetSize,
74         [Code::CMD_CLOSE] = &RdbResultSetStub::OnClose
75     };
76 RDB_UTILS_POP_WARNING
77     std::shared_ptr<NativeRdb::ResultSet> resultSet_;
78 };
79 } // namespace OHOS::DistributedRdb
80 #endif // DISTRIBUTED_RDB_RDB_RESULT_SET_STUB_H