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 NATIVE_RDB_RESULT_SET_PROXY_H
17 #define NATIVE_RDB_RESULT_SET_PROXY_H
18 
19 #include "iremote_proxy.h"
20 #include "iresult_set.h"
21 
22 namespace OHOS::NativeRdb {
23 class ResultSetProxy : public IRemoteProxy<IResultSet> {
24 public:
25     explicit ResultSetProxy(const sptr<IRemoteObject> &impl);
26     ~ResultSetProxy();
27     int GetColumnCount(int &count) override;
28     int GetColumnType(int columnIndex, ColumnType &columnType) override;
29     int GetRowCount(int &count) override;
30     int GetRowIndex(int &position) const override;
31     int GoTo(int offset) override;
32     int GoToRow(int position) override;
33     int GoToFirstRow() override;
34     int GoToLastRow() override;
35     int GoToNextRow() override;
36     int GoToPreviousRow() override;
37     int IsEnded(bool &result) override;
38     int IsStarted(bool &result) const override;
39     int IsAtFirstRow(bool &result) const override;
40     int IsAtLastRow(bool &result) override;
41     int Get(int32_t col, ValueObject &value) override;
42     int GetSize(int columnIndex, size_t &size) override;
43     int Close() override;
44 
45 protected:
46     std::pair<int, std::vector<std::string>> GetColumnNames() override;
47 
48 private:
49     // the max capacity for ipc is 800KB.
50     static const size_t MAX_IPC_CAPACITY = 800 * 1024;
51     template<typename... T>
52     int Send(uint32_t code, T &...output) const;
53 
54     template<typename... T>
55     int SendRequest(uint32_t code, MessageParcel &reply, const T &...input) const;
56 
57     sptr<IRemoteObject> remote_;
58 };
59 } // namespace OHOS::NativeRdb
60 #endif // NATIVE_RDB_RESULT_SET_PROXY_H
61