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 GetAllColumnNames(std::vector<std::string> &columnNames) override; 28 int GetColumnCount(int &count) override; 29 int GetColumnType(int columnIndex, ColumnType &columnType) override; 30 int GetColumnIndex(const std::string &columnName, int &columnIndex) override; 31 int GetColumnName(int columnIndex, std::string &columnName) override; 32 int GetRowCount(int &count) override; 33 int GetRowIndex(int &position) const override; 34 int GoTo(int offset) override; 35 int GoToRow(int position) override; 36 int GoToFirstRow() override; 37 int GoToLastRow() override; 38 int GoToNextRow() override; 39 int GoToPreviousRow() override; 40 int IsEnded(bool &result) override; 41 int IsStarted(bool &result) const override; 42 int IsAtFirstRow(bool &result) const override; 43 int IsAtLastRow(bool &result) override; 44 int GetBlob(int columnIndex, std::vector<uint8_t> &blob) override; 45 int GetString(int columnIndex, std::string &value) override; 46 int GetInt(int columnIndex, int &value) override; 47 int GetLong(int columnIndex, int64_t &value) override; 48 int GetDouble(int columnIndex, double &value) override; 49 int IsColumnNull(int columnIndex, bool &isNull) override; 50 bool IsClosed() const override; 51 int Close() override; 52 53 private: 54 // the max capacity for ipc is 800KB. 55 static const size_t MAX_IPC_CAPACITY = 800 * 1024; 56 sptr<IRemoteObject> remote_; 57 int SendRequest(uint32_t code); 58 int SendIntRequest(uint32_t code, int value); 59 int SendRequestRetBool(uint32_t code, bool &result) const; 60 int SendRequestRetInt(uint32_t code, int &result) const; 61 int SendRequestRetReply(uint32_t code, int columnIndex, MessageParcel &reply); 62 }; 63 } // namespace OHOS::NativeRdb 64 #endif // NATIVE_RDB_RESULT_SET_PROXY_H 65